@ -260,7 +260,9 @@ void Player::Update(float fElapsedTime){
if ( castInfo . castTimer > 0 ) {
if ( castInfo . castTimer > 0 ) {
castInfo . castTimer - = fElapsedTime ;
castInfo . castTimer - = fElapsedTime ;
if ( castInfo . castTimer < = 0 ) {
if ( castInfo . castTimer < = 0 ) {
if ( castPrepAbility - > action ( this , castInfo . castPos ) ) {
bool allowed = castPrepAbility - > actionPerformedDuringCast ;
if ( ! allowed & & castPrepAbility - > action ( this , castInfo . castPos ) ) allowed = true ;
if ( allowed ) {
castPrepAbility - > cooldown = castPrepAbility - > COOLDOWN_TIME ;
castPrepAbility - > cooldown = castPrepAbility - > COOLDOWN_TIME ;
ConsumeMana ( castPrepAbility - > manaCost ) ;
ConsumeMana ( castPrepAbility - > manaCost ) ;
}
}
@ -438,13 +440,11 @@ void Player::Update(float fElapsedTime){
if ( CanAct ( ability ) ) {
if ( CanAct ( ability ) ) {
if ( ability . cooldown = = 0 & & GetMana ( ) > = ability . manaCost ) {
if ( ability . cooldown = = 0 & & GetMana ( ) > = ability . manaCost ) {
if ( key . Held ( ) | | key . Released ( ) & & & ability = = castPrepAbility & & GetState ( ) = = State : : PREP_CAST ) {
if ( key . Held ( ) | | key . Released ( ) & & & ability = = castPrepAbility & & GetState ( ) = = State : : PREP_CAST ) {
if ( AllowedToCast ( ability ) ) {
if ( AllowedToCast ( ability ) & & ability . action ( this , { } ) ) {
bool allowed = ability . actionPerformedDuringCast ;
bool allowed = ability . actionPerformedDuringCast ;
if ( ! allowed & & ability . action ( this , { } ) ) allowed = true ;
ability . cooldown = ability . COOLDOWN_TIME ;
if ( allowed ) {
CancelCast ( ) ;
ability . cooldown = ability . COOLDOWN_TIME ;
ConsumeMana ( ability . manaCost ) ;
ConsumeMana ( ability . manaCost ) ;
}
} else
} else
if ( ability . precastInfo . precastTargetingRequired & & GetState ( ) = = State : : NORMAL ) {
if ( ability . precastInfo . precastTargetingRequired & & GetState ( ) = = State : : NORMAL ) {
PrepareCast ( ability ) ;
PrepareCast ( ability ) ;
@ -654,13 +654,17 @@ Key Player::GetFacingDirection(){
return facingDirection ;
return facingDirection ;
}
}
void Player : : CancelCast ( ) {
castInfo = { " " , 0 } ;
std : : erase_if ( buffList , [ ] ( Buff & b ) { return b . type = = RESTORATION_DURING_CAST ; } ) ; //Remove all buffs that would be applied during a cast, as we got interrupted.
DAMAGENUMBER_LIST . push_back ( std : : make_shared < DamageNumber > ( GetPos ( ) , 0 , true , INTERRUPT ) ) ;
}
void Player : : Moved ( ) {
void Player : : Moved ( ) {
if ( state = = State : : CASTING ) {
if ( state = = State : : CASTING ) {
state = State : : NORMAL ;
state = State : : NORMAL ;
castPrepAbility - > waitForRelease = true ;
castPrepAbility - > waitForRelease = true ;
castInfo = { " " , 0 } ;
CancelCast ( ) ;
std : : erase_if ( buffList , [ ] ( Buff & b ) { return b . type = = RESTORATION_DURING_CAST ; } ) ; //Remove all buffs that would be applied during a cast, as we got interrupted.
DAMAGENUMBER_LIST . push_back ( std : : make_shared < DamageNumber > ( GetPos ( ) , 0 , true , INTERRUPT ) ) ;
}
}
for ( MonsterSpawner & spawner : SPAWNER_LIST ) {
for ( MonsterSpawner & spawner : SPAWNER_LIST ) {
if ( ! spawner . SpawnTriggered ( ) & & spawner . DoesUpperLevelSpawning ( ) = = OnUpperLevel ( ) & & geom2d : : contains ( geom2d : : rect < float > { spawner . GetPos ( ) , spawner . GetRange ( ) } , pos ) ) {
if ( ! spawner . SpawnTriggered ( ) & & spawner . DoesUpperLevelSpawning ( ) = = OnUpperLevel ( ) & & geom2d : : contains ( geom2d : : rect < float > { spawner . GetPos ( ) , spawner . GetRange ( ) } , pos ) ) {