mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
Spells can now define color muxer effect (e.g. Bloodlust & Petrify)
This commit is contained in:
@@ -361,7 +361,7 @@ void BattleInterface::spellCast(const BattleSpellCast * sc)
|
|||||||
executeOnAnimationCondition(EAnimationEvents::BEFORE_HIT, true, [=]()
|
executeOnAnimationCondition(EAnimationEvents::BEFORE_HIT, true, [=]()
|
||||||
{
|
{
|
||||||
stacksController->addNewAnim(new CastAnimation(*this, casterStack, targetedTile, curInt->cb->battleGetStackByPos(targetedTile), spell));
|
stacksController->addNewAnim(new CastAnimation(*this, casterStack, targetedTile, curInt->cb->battleGetStackByPos(targetedTile), spell));
|
||||||
displaySpellCast(spellID, casterStack->getPosition());
|
displaySpellCast(spell, casterStack->getPosition());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -377,7 +377,7 @@ void BattleInterface::spellCast(const BattleSpellCast * sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
executeOnAnimationCondition(EAnimationEvents::HIT, true, [=](){
|
executeOnAnimationCondition(EAnimationEvents::HIT, true, [=](){
|
||||||
displaySpellHit(spellID, targetedTile);
|
displaySpellHit(spell, targetedTile);
|
||||||
});
|
});
|
||||||
|
|
||||||
//queuing affect animation
|
//queuing affect animation
|
||||||
@@ -388,12 +388,7 @@ void BattleInterface::spellCast(const BattleSpellCast * sc)
|
|||||||
if(stack)
|
if(stack)
|
||||||
{
|
{
|
||||||
executeOnAnimationCondition(EAnimationEvents::HIT, true, [=](){
|
executeOnAnimationCondition(EAnimationEvents::HIT, true, [=](){
|
||||||
if (spellID == SpellID::BLOODLUST)
|
displaySpellEffect(spell, stack->getPosition());
|
||||||
stacksController->addNewAnim( new ColorTransformAnimation(*this, stack, "bloodlust", spell));
|
|
||||||
else if (spellID == SpellID::STONE_GAZE)
|
|
||||||
stacksController->addNewAnim( new ColorTransformAnimation(*this, stack, "petrification", spell));
|
|
||||||
else
|
|
||||||
displaySpellEffect(spellID, stack->getPosition());
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -460,13 +455,22 @@ void BattleInterface::displayBattleLog(const std::vector<MetaString> & battleLog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleInterface::displaySpellAnimationQueue(const CSpell::TAnimationQueue & q, BattleHex destinationTile, bool isHit)
|
void BattleInterface::displaySpellAnimationQueue(const CSpell * spell, const CSpell::TAnimationQueue & q, BattleHex destinationTile, bool isHit)
|
||||||
{
|
{
|
||||||
for(const CSpell::TAnimation & animation : q)
|
for(const CSpell::TAnimation & animation : q)
|
||||||
{
|
{
|
||||||
if(animation.pause > 0)
|
if(animation.pause > 0)
|
||||||
stacksController->addNewAnim(new DummyAnimation(*this, animation.pause));
|
stacksController->addNewAnim(new DummyAnimation(*this, animation.pause));
|
||||||
else
|
|
||||||
|
if (!animation.effectName.empty())
|
||||||
|
{
|
||||||
|
const CStack * destStack = getCurrentPlayerInterface()->cb->battleGetStackByPos(destinationTile, false);
|
||||||
|
|
||||||
|
if (destStack)
|
||||||
|
stacksController->addNewAnim(new ColorTransformAnimation(*this, destStack, animation.effectName, spell ));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!animation.resourceName.empty())
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
@@ -487,28 +491,22 @@ void BattleInterface::displaySpellAnimationQueue(const CSpell::TAnimationQueue &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleInterface::displaySpellCast(SpellID spellID, BattleHex destinationTile)
|
void BattleInterface::displaySpellCast(const CSpell * spell, BattleHex destinationTile)
|
||||||
{
|
{
|
||||||
const CSpell * spell = spellID.toSpell();
|
|
||||||
|
|
||||||
if(spell)
|
if(spell)
|
||||||
displaySpellAnimationQueue(spell->animationInfo.cast, destinationTile, false);
|
displaySpellAnimationQueue(spell, spell->animationInfo.cast, destinationTile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleInterface::displaySpellEffect(SpellID spellID, BattleHex destinationTile)
|
void BattleInterface::displaySpellEffect(const CSpell * spell, BattleHex destinationTile)
|
||||||
{
|
{
|
||||||
const CSpell *spell = spellID.toSpell();
|
|
||||||
|
|
||||||
if(spell)
|
if(spell)
|
||||||
displaySpellAnimationQueue(spell->animationInfo.affect, destinationTile, false);
|
displaySpellAnimationQueue(spell, spell->animationInfo.affect, destinationTile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleInterface::displaySpellHit(SpellID spellID, BattleHex destinationTile)
|
void BattleInterface::displaySpellHit(const CSpell * spell, BattleHex destinationTile)
|
||||||
{
|
{
|
||||||
const CSpell * spell = spellID.toSpell();
|
|
||||||
|
|
||||||
if(spell)
|
if(spell)
|
||||||
displaySpellAnimationQueue(spell->animationInfo.hit, destinationTile, true);
|
displaySpellAnimationQueue(spell, spell->animationInfo.hit, destinationTile, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattleInterface::setAnimSpeed(int set)
|
void BattleInterface::setAnimSpeed(int set)
|
||||||
|
@@ -206,10 +206,10 @@ public:
|
|||||||
|
|
||||||
void displayBattleLog(const std::vector<MetaString> & battleLog);
|
void displayBattleLog(const std::vector<MetaString> & battleLog);
|
||||||
|
|
||||||
void displaySpellAnimationQueue(const CSpell::TAnimationQueue & q, BattleHex destinationTile, bool isHit);
|
void displaySpellAnimationQueue(const CSpell * spell, const CSpell::TAnimationQueue & q, BattleHex destinationTile, bool isHit);
|
||||||
void displaySpellCast(SpellID spellID, BattleHex destinationTile); //displays spell`s cast animation
|
void displaySpellCast(const CSpell * spell, BattleHex destinationTile); //displays spell`s cast animation
|
||||||
void displaySpellEffect(SpellID spellID, BattleHex destinationTile); //displays spell`s affected animation
|
void displaySpellEffect(const CSpell * spell, BattleHex destinationTile); //displays spell`s affected animation
|
||||||
void displaySpellHit(SpellID spellID, BattleHex destinationTile); //displays spell`s affected animation
|
void displaySpellHit(const CSpell * spell, BattleHex destinationTile); //displays spell`s affected animation
|
||||||
|
|
||||||
void endAction(const BattleAction* action);
|
void endAction(const BattleAction* action);
|
||||||
|
|
||||||
|
@@ -451,7 +451,7 @@ void BattleStacksController::stacksAreAttacked(std::vector<StackAttackedInfo> at
|
|||||||
owner.effectsController->displayEffect(EBattleEffect::FIRE_SHIELD, soundBase::FIRESHIE, attackedInfo.attacker->getPosition());
|
owner.effectsController->displayEffect(EBattleEffect::FIRE_SHIELD, soundBase::FIRESHIE, attackedInfo.attacker->getPosition());
|
||||||
|
|
||||||
if (attackedInfo.spellEffect != SpellID::NONE)
|
if (attackedInfo.spellEffect != SpellID::NONE)
|
||||||
owner.displaySpellEffect(attackedInfo.spellEffect, attackedInfo.defender->getPosition());
|
owner.displaySpellEffect(attackedInfo.spellEffect.toSpell(), attackedInfo.defender->getPosition());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,7 +606,7 @@ void BattleStacksController::stackAttacking( const StackAttackInfo & info )
|
|||||||
{
|
{
|
||||||
owner.executeOnAnimationCondition(EAnimationEvents::HIT, true, [=]()
|
owner.executeOnAnimationCondition(EAnimationEvents::HIT, true, [=]()
|
||||||
{
|
{
|
||||||
owner.displaySpellHit(spellEffect, tile);
|
owner.displaySpellHit(spellEffect.toSpell(), tile);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,9 @@
|
|||||||
"index" : 70,
|
"index" : 70,
|
||||||
"targetType": "NO_TARGET",
|
"targetType": "NO_TARGET",
|
||||||
"animation":{
|
"animation":{
|
||||||
//need special animation
|
"affect":[ {
|
||||||
|
"effectName" : "petrification"
|
||||||
|
} ]
|
||||||
},
|
},
|
||||||
"sounds": {
|
"sounds": {
|
||||||
"cast": "PARALYZE"
|
"cast": "PARALYZE"
|
||||||
|
@@ -437,7 +437,9 @@
|
|||||||
"targetType" : "CREATURE",
|
"targetType" : "CREATURE",
|
||||||
|
|
||||||
"animation":{
|
"animation":{
|
||||||
"affect":["SP12_"] //???
|
"affect":[ {
|
||||||
|
"effectName" : "bloodlust"
|
||||||
|
} ]
|
||||||
},
|
},
|
||||||
"sounds": {
|
"sounds": {
|
||||||
"cast": "BLOODLUS"
|
"cast": "BLOODLUS"
|
||||||
|
@@ -522,8 +522,9 @@ void CSpell::serializeJson(JsonSerializeFormat & handler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
///CSpell::AnimationInfo
|
///CSpell::AnimationInfo
|
||||||
CSpell::AnimationItem::AnimationItem()
|
CSpell::AnimationItem::AnimationItem() :
|
||||||
:resourceName(""),verticalPosition(VerticalPosition::TOP),pause(0)
|
verticalPosition(VerticalPosition::TOP),
|
||||||
|
pause(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -890,6 +891,7 @@ CSpell * CSpellHandler::loadFromJson(const std::string & scope, const JsonNode &
|
|||||||
else if(item.getType() == JsonNode::JsonType::DATA_STRUCT)
|
else if(item.getType() == JsonNode::JsonType::DATA_STRUCT)
|
||||||
{
|
{
|
||||||
newItem.resourceName = item["defName"].String();
|
newItem.resourceName = item["defName"].String();
|
||||||
|
newItem.effectName = item["effectName"].String();
|
||||||
|
|
||||||
auto vPosStr = item["verticalPosition"].String();
|
auto vPosStr = item["verticalPosition"].String();
|
||||||
if("bottom" == vPosStr)
|
if("bottom" == vPosStr)
|
||||||
|
@@ -76,6 +76,7 @@ public:
|
|||||||
struct AnimationItem
|
struct AnimationItem
|
||||||
{
|
{
|
||||||
std::string resourceName;
|
std::string resourceName;
|
||||||
|
std::string effectName;
|
||||||
VerticalPosition verticalPosition;
|
VerticalPosition verticalPosition;
|
||||||
int pause;
|
int pause;
|
||||||
|
|
||||||
@@ -84,6 +85,7 @@ public:
|
|||||||
template <typename Handler> void serialize(Handler & h, const int version)
|
template <typename Handler> void serialize(Handler & h, const int version)
|
||||||
{
|
{
|
||||||
h & resourceName;
|
h & resourceName;
|
||||||
|
h & effectName;
|
||||||
h & verticalPosition;
|
h & verticalPosition;
|
||||||
h & pause;
|
h & pause;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user