10000 Improve viewing of "stand-alone" effect animations by LynxAbraxas · Pull Request #427 · civctp2/civctp2 · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve viewing of "stand-alone" effect animations #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
use locking for "stand-alone" effect animations but not for projectiles:
- without "stand-alone" effect animations are hardly ever visible due to other changes of map center
- projectile animations should play together with (special) attack animations, so they should not lock
  • Loading branch information
LynxAbraxas committed Dec 30, 2024
commit 49ff2d27bcd148e9e72a81650ca4e247bd0b5c3b
43 changes: 30 additions & 13 deletions ctp2_code/gfx/spritesys/director.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class DQAnimationStandby : public DQAnimation {
*
* The combination of the two behaviours will create four kind of actions:
* - No Lock && No Animation -> immediate
* - No Lock && Animation -> effect
* - Lock && Animation -> effect (EffectActor, similar to active now that locking was enabled here as well)
* - Lock && No Animation -> external
* - Lock && Animation -> active
*
Expand Down Expand Up @@ -422,9 +422,9 @@ class DQActionImmediate : public DQAction {
};

/**
* DQActionEffect: No Lock and Animation
* DQActionEffect: Lock and Animation (EffectActor)
* -> LoopingSound is ignored
* -> IsUnlocked returns true
* -> IsUnlocked returns true when animation is done
* -> IsAnimationFinished returns true when animation is done
*/
class DQActionEffect : public DQAction {
Expand All @@ -447,7 +447,7 @@ class DQActionEffect : public DQAction {

// Lock behaviour
virtual void Unlock() {}
virtual bool IsUnlocked() { return true; }
virtual bool IsUnlocked() { return IsAnimationFinished(); }

// Animation behaviour
virtual void Process()
Expand All @@ -471,6 +471,24 @@ class DQActionEffect : public DQAction {
EffectActor *m_activeActor;
};

/**
* DQActionEffectNoLock: like DQActionEffect but No Lock (for projectiles)
* -> LoopingSound is ignored
* -> IsUnlocked returns true
* -> IsAnimationFinished returns true when animation is done
*/
class DQActionEffectNoLock : public DQActionEffect {
public:
DQActionEffectNoLock(SpriteState *spriteState, const MapPoint &pos)
: DQActionEffect(spriteState, pos)
{}
DQActionEffectNoLock(sint32 spriteID, const MapPoint &pos)
: DQActionEffect(spriteID, pos)
{}

virtual bool IsUnlocked() { return true; }
};

/**
* DQActionExternal: Lock, and No Animation
* -> LoopingSound is terminated
Expand Down Expand Up @@ -1326,13 +1344,11 @@ class DQActionInvokeThroneRoom : public DQActionImmediate
}
};

class DQActionMoveProjectile : public DQActionEffect
class DQActionMoveProjectile : public DQActionEffectNoLock
{
public:
DQActionMoveProjectile(SpriteState *projectileEndState, const MapPoint &startPos, const MapPoint &endPos)
: DQActionEffect(projectileEndState, endPos),
startPos (startPos),
endPos (endPos)
: DQActionEffectNoLock(projectileEndState, endPos), startPos (startPos), endPos(endPos)
{}
virtual ~DQActionMoveProjectile() {}
virtual DQACTION_TYPE GetType() { return DQACTION_MOVEPROJECTILE; }
Expand Down Expand Up @@ -1362,11 +1378,11 @@ class DQActionMoveProjectile : public DQActionEffect
MapPoint endPos;
};

class DQActionCombatFlash : public DQActionEffect
class DQActionCombatFlash : public DQActionEffectNoLock
{
public:
DQActionCombatFlash(const MapPoint &flashPos)
: DQActionEffect(99, flashPos)
: DQActionEffectNoLock(99, flashPos)
{}
virtual ~DQActionCombatFlash() {}
virtual DQACTION_TYPE GetType() { return DQACTION_COMBATFLASH; }
Expand Down Expand Up @@ -1409,13 +1425,14 @@ class DQActionSpecialEffect : public DQActionEffect
Anim *animation = m_activeActor->CreatePlayAnim();
if (animation)
{
Action *action = Action::CreateEffectAction(EFFECTACTION_PLAY, animation);
m_activeActor->SetAction(action);

if (g_soundManager)
{
g_soundManager->AddSound(SOUNDTYPE_SFX, 0, soundID, pos.x, pos.y);
}


Action *action = Action::CreateEffectAction(EFFECTACTION_PLAY, animation);
m_activeActor->SetAction(action);
}
}
}
Expand Down
0