1
0
mirror of https://github.com/vcmi/vcmi.git synced 2026-05-22 09:55:17 +02:00

Add distinct animation type for unit teleportation animation

This commit is contained in:
Ivan Savenko
2026-01-23 11:19:18 +00:00
parent 9d23f239a5
commit c8497127e9
4 changed files with 35 additions and 14 deletions
+12 -4
View File
@@ -456,14 +456,18 @@ bool MovementEndAnimation::init()
ENGINE->sound().playSound(stack->unitType()->sounds.endMoving);
if(!myAnim->framesInGroup(ECreatureAnimType::MOVE_END))
auto groupID = ECreatureAnimType::MOVE_END;
if (stack->hasBonus(Selector::typeSubtype(BonusType::FLYING, BonusCustomSubtype::movementTeleporting)) && myAnim->framesInGroup(ECreatureAnimType::TELEPORT_END))
groupID = ECreatureAnimType::TELEPORT_END;
if(!myAnim->framesInGroup(groupID))
{
delete this;
return false;
}
myAnim->setType(ECreatureAnimType::MOVE_END);
myAnim->setType(groupID);
myAnim->onAnimationReset += [&](){ delete this; };
return true;
@@ -497,13 +501,17 @@ bool MovementStartAnimation::init()
logAnim->debug("CMovementStartAnimation::init: stack %s", stack->getName());
ENGINE->sound().playSound(stack->unitType()->sounds.startMoving);
if(!myAnim->framesInGroup(ECreatureAnimType::MOVE_START))
auto groupID = ECreatureAnimType::MOVE_START;
if (stack->hasBonus(Selector::typeSubtype(BonusType::FLYING, BonusCustomSubtype::movementTeleporting)) && myAnim->framesInGroup(ECreatureAnimType::TELEPORT_START))
groupID = ECreatureAnimType::TELEPORT_START;
if(!myAnim->framesInGroup(groupID))
{
delete this;
return false;
}
myAnim->setType(ECreatureAnimType::MOVE_START);
myAnim->setType(groupID);
myAnim->onAnimationReset += [&](){ delete this; };
return true;
}
+4 -1
View File
@@ -96,5 +96,8 @@ enum class ECreatureAnimType
GROUP_ATTACK_UP = 40,
GROUP_ATTACK_FRONT = 41,
GROUP_ATTACK_DOWN = 42
GROUP_ATTACK_DOWN = 42,
TELEPORT_START = 50,
TELEPORT_END = 51,
};
+4
View File
@@ -110,6 +110,8 @@ float AnimationControls::getCreatureAnimationSpeed(const CCreature * creature, c
case ECreatureAnimType::MOVE_START:
case ECreatureAnimType::MOVE_END:
case ECreatureAnimType::TELEPORT_START:
case ECreatureAnimType::TELEPORT_END:
return speed;
case ECreatureAnimType::DEAD:
@@ -389,8 +391,10 @@ bool CreatureAnimation::isIdle() const
bool CreatureAnimation::isMoving() const
{
return getType() == ECreatureAnimType::MOVE_START
|| getType() == ECreatureAnimType::TELEPORT_START
|| getType() == ECreatureAnimType::MOVING
|| getType() == ECreatureAnimType::MOVE_END
|| getType() == ECreatureAnimType::TELEPORT_END
|| getType() == ECreatureAnimType::TURN_L
|| getType() == ECreatureAnimType::TURN_R;
}
+15 -9
View File
@@ -124,7 +124,7 @@ TODO
Animation for creatures consist from multiple groups, with each group
representing one specific animation. VCMI uses groups as follows:
**Basic animations**
#### Basic animations
- [0] Movement: Used for creature movement
- [1] Mouse over: Used for random idle movements and when mouse is moved on the creature
@@ -134,50 +134,56 @@ representing one specific animation. VCMI uses groups as follows:
- [5] Death: Animation that plays when stack dies
- [6] Death (ranged): Alternative animation, plays when stack is killed by ranged attack
**Rotation animations**
#### Rotation animations
- [7] Turn left: Animation for rotating stack, only contains first part of animation, with stack turning towards viewer
- [8] Turn right: Second part of animation for rotating stack
- [9] (unused in vcmi, present in H3 files)
- [10] (unused in vcmi, present in H3 files)
**Melee attack animations**
#### Melee attack animations
- [11] Attack (up): Attacking animation, stack facing upwards
- [12] Attack (front): Attacking animation, stack facing front
- [13] Attack (down): Attacking animation, stack facing downwards
**Ranged attack animations**
#### Ranged attack animations
- [14] Shooting (up): Ranged attack animation, stack facing upwards
- [15] Shooting (front): Ranged attack animation, stack facing front
- [16] Shooting (down): Ranged attack animation, stack facing downwards
**Special animations**
#### Special animations
- [17] Special (up): Special animation, used if dedicated cast or group attack animations were not found
- [18] Special (front): Special animation, used if dedicated cast or group attack animations were not found
- [19] Special (down): Special animation, used if dedicated cast or group attack animations were not found
**Additional H3 animations**
#### Additional H3 animations
- [20] Movement start: Animation that plays before movement animation starts.
- [21] Movement end: Animation that plays after movement animation ends.
**Additional VCMI animations**
#### Additional VCMI animations
- [22] Dead: Animation that plays when creature is dead. If not present, will consist from last frame from "Death" group
- [23] Dead (ranged): Animation that plays when creature is dead after ranged attack. If not present, will consist from last frame from "Death (ranged)" group
- [24] Resurrection: Animation that plays when creature is resurrected. If not present, will consist from reversed version of "Death" animation
**Spellcasting animations**
#### Spellcasting animations
- [30] Cast (up): Used when creature casts spell facing upwards
- [31] Cast (front): Used when creature casts spell facing front
- [32] Cast (down): Used when creature casts spell facing downwards
**Group attack animations**
#### Group attack animations
- [40] Group Attack (up): Used when creature attacks multiple target, with primary target facing up (Dragon Breath attack, or creatures like Hydra)
- [41] Group Attack (front): Used when creature attacks multiple target, with primary target facing front (Dragon Breath attack, or creatures like Hydra)
- [42] Group Attack (down): Used when creature attacks multiple target, with primary target facing downwards (Dragon Breath attack, or creatures like Hydra)
#### Additional H3 animations
- [50] Teleportation start: Animation that plays on original unit position when unit teleports. If not present, movement start will play instead
- [51] Teleportation end: Animation that plays on destination position when unit teleports. If not present, movement end will play instead