@ -122,6 +122,7 @@ void Player::Initialize(){
afterImage . Decal ( ) - > Update ( ) ;
afterImage . Decal ( ) - > Update ( ) ;
playerOutline . Create ( 24 , 24 ) ;
playerOutline . Create ( 24 , 24 ) ;
shield . reserve ( SHIELD_CAPACITY ) ;
shield . reserve ( SHIELD_CAPACITY ) ;
DeactivateCatForm ( ) ;
}
}
void Player : : OnLevelStart ( ) {
void Player : : OnLevelStart ( ) {
@ -442,14 +443,14 @@ void Player::Update(float fElapsedTime){
if ( lastAnimationFlip = = 0 ) {
if ( lastAnimationFlip = = 0 ) {
lastAnimationFlip = 0.03f ;
lastAnimationFlip = 0.03f ;
facingDirection = DOWN ;
facingDirection = DOWN ;
animation . ChangeState ( internal_animState , " WARRIOR_WALK_S " ) ;
Upd ateA nimation( " WARRIOR_WALK_S " ) ;
}
}
} break ;
} break ;
case DOWN : {
case DOWN : {
if ( lastAnimationFlip = = 0 ) {
if ( lastAnimationFlip = = 0 ) {
lastAnimationFlip = 0.03f ;
lastAnimationFlip = 0.03f ;
facingDirection = UP ;
facingDirection = UP ;
animation . ChangeState ( internal_animState , " WARRIOR_WALK_N " ) ;
Upd ateA nimation( " WARRIOR_WALK_N " ) ;
}
}
} break ;
} break ;
}
}
@ -499,7 +500,7 @@ void Player::Update(float fElapsedTime){
if ( lastAnimationFlip > 0 ) {
if ( lastAnimationFlip > 0 ) {
lastAnimationFlip = std : : max ( 0.f , lastAnimationFlip - fElapsedTime ) ;
lastAnimationFlip = std : : max ( 0.f , lastAnimationFlip - fElapsedTime ) ;
}
}
animation . UpdateState ( internal_animState , fElapsedTime ) ;
UpdateAnimationStates ( ) ;
} break ;
} break ;
case State : : BLOCK : {
case State : : BLOCK : {
if ( blockTimer < = 0 ) {
if ( blockTimer < = 0 ) {
@ -524,7 +525,7 @@ void Player::Update(float fElapsedTime){
} break ;
} break ;
}
}
}
}
animation . UpdateState ( internal_animState , fElapsedTime ) ;
UpdateAnimationStates ( ) ;
} break ;
} break ;
case State : : TELEPORT : {
case State : : TELEPORT : {
teleportAnimationTimer = std : : max ( 0.f , teleportAnimationTimer - fElapsedTime ) ;
teleportAnimationTimer = std : : max ( 0.f , teleportAnimationTimer - fElapsedTime ) ;
@ -532,7 +533,7 @@ void Player::Update(float fElapsedTime){
ForceSetPos ( teleportTarget ) ;
ForceSetPos ( teleportTarget ) ;
SetState ( State : : NORMAL ) ;
SetState ( State : : NORMAL ) ;
}
}
animation . UpdateState ( internal_animState , fElapsedTime ) ;
UpdateAnimationStates ( ) ;
} break ;
} break ;
case State : : ROLL : {
case State : : ROLL : {
footstepTimer - = fElapsedTime ;
footstepTimer - = fElapsedTime ;
@ -584,11 +585,11 @@ void Player::Update(float fElapsedTime){
}
}
SetZ ( ( sin ( ( 1.f / totalLeapTime ) * PI * leapTimer ) / 2.f ) * " Witch.Right Click Ability.Leap Max Z " _F ) ;
SetZ ( ( sin ( ( 1.f / totalLeapTime ) * PI * leapTimer ) / 2.f ) * " Witch.Right Click Ability.Leap Max Z " _F ) ;
SetVelocity ( vf2d { " Witch.Right Click Ability.Leap Velocity " _F / 100.f * 24 , transformTargetDir } . cart ( ) ) ;
SetVelocity ( vf2d { " Witch.Right Click Ability.Leap Velocity " _F / 100.f * 24 , transformTargetDir } . cart ( ) ) ;
animation . UpdateState ( internal_animState , fElapsedTime ) ;
UpdateAnimationStates ( ) ;
} break ;
} break ;
default : {
default : {
//Update animations normally.
//Update animations normally.
animation . UpdateState ( internal_animState , fElapsedTime ) ;
UpdateAnimationStates ( ) ;
}
}
}
}
@ -947,7 +948,11 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z,const TrueDamageFlag dama
if ( tookLethalDamage & & survivedHitDueToDefiance ) ApplyIframes ( " Death Defiance " _ENC [ " LETHAL DAMAGE SURVIVE IFRAME TIME " ] ) ;
if ( tookLethalDamage & & survivedHitDueToDefiance ) ApplyIframes ( " Death Defiance " _ENC [ " LETHAL DAMAGE SURVIVE IFRAME TIME " ] ) ;
else {
else {
if ( GetShield ( ) > 0 ) {
if ( CatFormActive ( ) ) {
tookShieldDamage = true ;
if ( PlayHitSoundEffect ) SoundEffect : : PlaySFX ( " Warrior Block Hit " , SoundEffect : : CENTERED ) ;
DeactivateCatForm ( ) ;
} else if ( GetShield ( ) > 0 ) {
tookShieldDamage = true ;
tookShieldDamage = true ;
if ( PlayHitSoundEffect ) SoundEffect : : PlaySFX ( " Warrior Block Hit " , SoundEffect : : CENTERED ) ;
if ( PlayHitSoundEffect ) SoundEffect : : PlaySFX ( " Warrior Block Hit " , SoundEffect : : CENTERED ) ;
SubtractShield ( mod_dmg ) ;
SubtractShield ( mod_dmg ) ;
@ -1009,13 +1014,18 @@ void Player::AddAnimation(std::string state){
void Player : : UpdateAnimation ( std : : string animState , int specificClass , const float frameMult ) {
void Player : : UpdateAnimation ( std : : string animState , int specificClass , const float frameMult ) {
if ( specificClass = = ANY | | specificClass & GetClass ( ) ) {
if ( specificClass = = ANY | | specificClass & GetClass ( ) ) {
animation . ChangeState ( internal_animState , animState , frameMult ) ;
animation . ChangeState ( internal_animState , animState , frameMult ) ;
animation . ChangeState ( internal_catAnimState , std : : format ( " WITCH_CAT_WALK_{} " , animState [ animState . length ( ) - 1 ] ) , frameMult ) ;
}
}
}
}
Animate2D : : Frame Player : : GetFrame ( ) {
const Animate2D : : Frame & Player : : GetFrame ( ) const {
return animation . GetFrame ( internal_animState ) ;
return animation . GetFrame ( internal_animState ) ;
}
}
const Animate2D : : Frame & Player : : GetCatFrame ( ) const {
return animation . GetFrame ( internal_catAnimState ) ;
}
void Player : : SetFacingDirection ( Key direction ) {
void Player : : SetFacingDirection ( Key direction ) {
facingDirection = direction ;
facingDirection = direction ;
}
}
@ -1117,6 +1127,7 @@ void Player::UpdateIdleAnimation(Key direction){
}
}
SetFacingDirection ( direction ) ;
SetFacingDirection ( direction ) ;
UpdateAnimation ( anim ) ;
UpdateAnimation ( anim ) ;
animation . ChangeState ( internal_catAnimState , std : : format ( " WITCH_CAT_WALK_{} " , anim [ anim . length ( ) - 1 ] ) , 0.f ) ;
}
}
void Player : : AddBuff ( BuffType type , float duration , float intensity ) {
void Player : : AddBuff ( BuffType type , float duration , float intensity ) {
@ -1514,6 +1525,10 @@ void Player::RecalculateEquipStats(){
}
}
}
}
if ( GetClass ( ) & WITCH ) {
if ( HasEnchant ( " Nine Lives " ) ) GetRightClickAbility ( ) . COOLDOWN_TIME = " Nine Lives " _ENC [ " TRANSFORM COOLDOWN " ] ;
}
for ( const std : : reference_wrapper < Ability > & a : GetAbilities ( ) ) {
for ( const std : : reference_wrapper < Ability > & a : GetAbilities ( ) ) {
if ( a . get ( ) . itemAbility ) continue ;
if ( a . get ( ) . itemAbility ) continue ;
if ( a . get ( ) . charges < a . get ( ) . MAX_CHARGES & & a . get ( ) . cooldown = = 0.f ) a . get ( ) . cooldown = a . get ( ) . GetCooldownTime ( ) ;
if ( a . get ( ) . charges < a . get ( ) . MAX_CHARGES & & a . get ( ) . cooldown = = 0.f ) a . get ( ) . cooldown = a . get ( ) . GetCooldownTime ( ) ;
@ -2019,11 +2034,11 @@ const bool Player::HasEnchant(const std::string_view enchantName)const{
}
}
void Player : : OnAbilityUse ( const Ability & ability ) {
void Player : : OnAbilityUse ( const Ability & ability ) {
if ( ability . itemAbility | | ability . name = = GetRightClickAbility ( ) . name ) return ;
if ( ability . itemAbility ) return ;
const auto UsedAbility = [ & ability ] ( const std : : string_view abilityName ) { return ability . name = = abilityName ; } ;
const auto UsedAbility = [ & ability ] ( const std : : string_view abilityName ) { return ability . name = = abilityName ; } ;
if ( HasEnchant ( " Wizard's Soul " ) ) {
if ( HasEnchant ( " Wizard's Soul " ) & & ability . name ! = GetRightClickAbility ( ) . name ) {
const auto ReduceCooldown = [ this , & ability ] ( Ability & a ) {
const auto ReduceCooldown = [ this , & ability ] ( Ability & a ) {
if ( ability . name = = a . name ) return ;
if ( ability . name = = a . name ) return ;
a . cooldown - = " Wizard's Soul " _ENC [ " ABILITY COOLDOWN AMOUNT " ] ;
a . cooldown - = " Wizard's Soul " _ENC [ " ABILITY COOLDOWN AMOUNT " ] ;
@ -2052,6 +2067,10 @@ void Player::OnAbilityUse(const Ability&ability){
CancelTimer ( PlayerTimerType : : DEADLY_MIRAGE_SECOND_CAST ) ;
CancelTimer ( PlayerTimerType : : DEADLY_MIRAGE_SECOND_CAST ) ;
}
}
}
}
if ( UsedAbility ( " Transform " ) & & HasEnchant ( " Nine Lives " ) ) {
if ( HasTimer ( PlayerTimerType : : CAT_FORM_ALREADY_ACTIVE ) & & GetTimer ( PlayerTimerType : : CAT_FORM_ALREADY_ACTIVE ) . IsRunning ( ) ) Witch : : rightClickAbility . cooldown = " Witch.Right Click Ability.Cooldown " _F ;
}
}
}
Ability & Player : : GetItem1 ( ) {
Ability & Player : : GetItem1 ( ) {
@ -2211,3 +2230,17 @@ void Player::NotEnoughManaDisplay(const std::string_view text,const float displa
void Player : : NotificationDisplay ( const std : : string_view text , const float displayTime ) {
void Player : : NotificationDisplay ( const std : : string_view text , const float displayTime ) {
notificationDisplay = std : : pair < std : : string , float > { text , displayTime } ;
notificationDisplay = std : : pair < std : : string , float > { text , displayTime } ;
}
}
void Player : : DeactivateCatForm ( ) {
catForm = false ;
}
void Player : : ActivateCatForm ( ) {
catForm = true ;
}
const bool Player : : CatFormActive ( ) const {
return catForm ;
}
void Player : : UpdateAnimationStates ( ) {
animation . UpdateState ( internal_animState , game - > GetElapsedTime ( ) ) ;
animation . UpdateState ( internal_catAnimState , game - > GetElapsedTime ( ) ) ;
}