DoDamageAnim¶
This coroutine is only called as part of DoDamage when applicable and as part of UseItem when processing a HPto1
item use.
It only performs animstate and other visual update on an actor to indicate that they have sustained damage.
private IEnumerator DoDamageAnim(MainManager.BattleData entity, int damage, bool block, bool nosound, bool fail, bool noanim, bool fakeanim)
There is a coroutine overload available that starts this one where nosound
, fail
, noanim
and fakeanim
are all false with the only logic difference being there's a frame yield after the coroutine started.
Parameters¶
entity
: The actor sustaining the damagedamage
: The amount of damage the actor is sustainingblock
: If the actor is a player party member, whether the player sucessfully blocked the damage it is sustainingnosound
: If true, no sound will be playedfail
: Ifnosound
is false, this tells if the player failed the attack's action command which changes some logic regarding sounds being played. This is ignored ifnosound
is truenoanim
: If true, there won't be any animstate updates on the actor even if entity.battleentity.overridenanim
is falsefakeanim
: Ifnoanim
is false, this changes the animstate value to set the actor's battleentity to 30 (FakeHurt
) instead of 11 (Hurt
) when damage is above 0 and block is false. This is ignored ifnoanim
is true,damage
isn't above 0 orblock
is true.
Procedure¶
The following describes the logic divided by sections as it contains a lot of conditional logic.
overrideanim
¶
If noanim and entity.battleentity.overrideanim
are false, entity.battleentity.overrideanim
is set to true
nosound is false¶
This part is skipped if nosound is true:
- If fail is true, the
AtkFail
sound is played - If block is true, the
Block
sound is played if it wasn't playing already with a time of 0.1 seconds or below - If damage is above 0 while block is false, the
Damage0
sound is played if it wasn't already with a time of 0.1 seconds or below. As for the pitch and volume:- If fail is true, the pitch is 0.7 and volume is 0.6
- If fail is false, the pitch is 1.0 + combo * 0.125 and the volume is 1.0
- If damage is above 0 while block is false, the
WoodHit
sound is played with a volume of 0.8 if it wasn't playing already with a time of 0.1 seconds or below
damage is above 0¶
This part is skipped if no damage was sustained
- The
hitpart
is played at entity.battleentity's position + (0.0, entity.cursoroffset
.y / 2.0 + entity.battleentity.height
, 0.0) - If MainManager.
screenshake
's magnitude is below 0.05, ShakeScreen is called with an ammount of (0.1, 0.1, 0.1) for 0.15 seconds with dontreset to true
noanim yield break¶
If entity.battleentity.overrideanim
or noanim is true, the coroutine ends here with a yield break
Animation updates¶
The rest of the logic deals with visual animations.
First animstate logic¶
entity.battleentity.animstate may be set depending on conditions (mutually exclusive, only the first one applies in order):
- 21 (
Woobly
) if entity has the Topple animation - 16 (
HurtFallen
), if entity has the Flipped animation - If damage is above 0:
- 24 (
Block
) if block is true - 11 (
Hurt
) if block is false. This is 30 (FakeHurt
) instead if fakeanim is true
- 24 (
- If none of the above happened:
- It's set to 24 (
Block
) if block is true - A ShakeSprite coroutine starts on the entity.battleentity with an intensity of (0.1, 0.0, 0.0) and a frametimer of 20.0
- It's set to 24 (
- 0.35 seconds are yielded
Topple animation¶
There are some special handling on top of the above if entity has the Topple animation:
- entity.battleentity.
basestate
is set to 21 (Woobly
) - entity.battleentity.
overrideanim
is set to false - entity.battleentity.animstate is set to its
basestate
Flipped animation¶
If the Topple logic above didn't apply, but entity has the Flipped animation:
- entity.battleentity.
basestate
is set to 15 (Fallen
) - entity.battleentity.
overrideanim
is set to false - entity.battleentity.animstate is set to its
basestate
Alive animation (entity.hp
is above 0)¶
The following applies on top of all the animations logic above if entity.hp
is above 0:
- entity.battleentity.
overrideanim
is set to false - if entity has the Sleep condition, entity.battleentity.animstate is set to 14 (
Sleep
) - Otherwise, if the entity is a player party member with an
hp
of 4 or below, its animstate is set to 17 (WeakBattleIdle
) - Otherwise, entity.battleentity.animstate is set to its value before this coroutine started unless it was 31 (
Dig
) or 32 (DigMove
) where it's thebasestate
it had at the start instead