@ -42,15 +42,25 @@ All rights reserved.
INCLUDE_game
PurpleEnergyBall : : PurpleEnergyBall ( vf2d pos , float radius , float homingRadius , int damage , bool upperLevel , vf2d speed , bool hitsMultiple , float lifetime , bool friendly , Pixel col , vf2d scale )
: initialScale ( scale ) , homingRadius ( homingRadius ) , Bullet ( pos , speed , radius , damage , " mark_trail.png " , upperLevel , hitsMultipl e, INFINITE , false , friendly , col , scale / 2.f , 0.f ) { }
PurpleEnergyBall : : PurpleEnergyBall ( vf2d pos , float radius , float homingRadius , int damage , bool upperLevel , vf2d speed , float lifetime , bool friendly , Pixel col , vf2d scale )
: initialScale ( scale ) , homingRadius ( homingRadius ) , bounceCount ( game - > GetPlayer ( ) - > HasEnchant ( " Bouncing Orb " ) ? " Bouncing Orb " _ENC [ " BOUNCE COUNT " ] : 1 ) , Bullet ( pos , speed , radius , damage , " mark_trail.png " , upperLevel , tru e, INFINITE , false , friendly , col , scale / 2.f , 0.f ) { }
void PurpleEnergyBall : : Update ( float fElapsedTime ) {
if ( IsDeactivated ( ) ) {
if ( lastHitTimer > 0.f ) {
lastHitTimer - = fElapsedTime ;
if ( lastHitTimer < = 0.f ) {
lastHitTimer = 0.f ;
Activate ( ) ;
}
} else return ;
}
if ( homingTarget . has_value ( ) ) {
if ( ! homingTarget . value ( ) . expired ( ) ) {
const bool TargetInRange { util : : distance ( pos , homingTarget . value ( ) . lock ( ) - > GetPos ( ) ) < = " Witch.Auto Attack.Homing Range " _F } ;
const bool TargetIsAlive { homingTarget . value ( ) . lock ( ) - > IsAlive ( ) } ;
if ( TargetIsAlive & & TargetInRange ) {
if ( TargetIsAlive & & TargetInRange & & ( ! lastHitTarget | | lastHitTarget & & ! lastHitTarget . value ( ) . expired ( ) & & & * homingTarget . value ( ) . lock ( ) ! = & * lastHitTarget . value ( ) . lock ( ) ) ) {
const float targetAngle { util : : angleTo ( pos , homingTarget . value ( ) . lock ( ) - > GetPos ( ) ) } ;
float currentAngle { vel . polar ( ) . y } ;
util : : turn_towards_direction ( currentAngle , targetAngle , util : : degToRad ( " Witch.Auto Attack.Homing Turning Radius " _F ) * fElapsedTime ) ;
@ -61,7 +71,7 @@ void PurpleEnergyBall::Update(float fElapsedTime){
} else {
homingTarget . reset ( ) ;
}
} else homingTarget = Monster : : GetNearestMonster ( pos , " Witch.Auto Attack.Homing Range " _F , OnUpperLevel ( ) , GetZ ( ) ) ;
} else homingTarget = Monster : : GetNearestMonster ( pos , " Witch.Auto Attack.Homing Range " _F , OnUpperLevel ( ) , GetZ ( ) , lastHitTarget ) ;
if ( distanceTraveled > " Witch.Auto Attack.Range " _F & & IsActivated ( ) ) {
fadeOutTime = " Witch.Auto Attack.BulletHitFadeoutTime " _F ;
}
@ -79,7 +89,10 @@ void PurpleEnergyBall::Draw(const Pixel blendCol)const{
BulletDestroyState PurpleEnergyBall : : PlayerHit ( Player * player )
{
fadeOutTime = " Witch.Auto Attack.BulletHitFadeoutTime " _F ;
bounceCount - - ;
if ( bounceCount < = 0 ) fadeOutTime = " Witch.Auto Attack.BulletHitFadeoutTime " _F ;
else lastHitTimer = 0.1f ;
Deactivate ( ) ;
std : : unique_ptr < Effect > hitEffect { std : : make_unique < Effect > ( player - > GetPos ( ) , 0 , " purpleenergyball_hit.png " , upperLevel , player - > GetSizeMult ( ) , " Witch.Auto Attack.SplashEffectFadeoutTime " _F , vf2d { } , WHITE , util : : random ( 2 * PI ) , 5 * PI ) } ;
hitEffect - > scaleSpd = { - 0.3f , - 0.3f } ;
game - > AddEffect ( std : : move ( hitEffect ) ) ;
@ -88,7 +101,12 @@ BulletDestroyState PurpleEnergyBall::PlayerHit(Player*player)
BulletDestroyState PurpleEnergyBall : : MonsterHit ( Monster & monster , const uint8_t markStacksBeforeHit )
{
fadeOutTime = " Witch.Auto Attack.BulletHitFadeoutTime " _F ;
bounceCount - - ;
hitList . clear ( ) ;
lastHitTarget = monster . GetWeakPointer ( ) ;
if ( bounceCount < = 0 ) fadeOutTime = " Witch.Auto Attack.BulletHitFadeoutTime " _F ;
else lastHitTimer = 0.1f ;
Deactivate ( ) ;
std : : unique_ptr < Effect > hitEffect { std : : make_unique < Effect > ( monster . GetPos ( ) , 0 , " purpleenergyball_hit.png " , upperLevel , monster . GetSizeMult ( ) , " Witch.Auto Attack.SplashEffectFadeoutTime " _F , vf2d { } , WHITE , util : : random ( 2 * PI ) , 5 * PI ) } ;
hitEffect - > scaleSpd = { - 0.3f , - 0.3f } ;
game - > AddEffect ( std : : move ( hitEffect ) ) ;