@ -61,6 +61,7 @@ void Monster::STRATEGY::GOBLIN_BOW(Monster&m,float fElapsedTime,std::string stra
enum PhaseName {
INITIALIZE_PERCEPTION ,
MOVE ,
LOCKON ,
WINDUP ,
} ;
# pragma endregion
@ -78,7 +79,7 @@ void Monster::STRATEGY::GOBLIN_BOW(Monster&m,float fElapsedTime,std::string stra
const bool outsideMaxShootingRange = distToPlayer > = ConfigPixelsArr ( " Stand Still and Shoot Range " , 1 ) ;
auto PrepareToShoot = [ & ] ( ) {
m . phase = WINDUP ;
m . phase = LOCKON ;
m . F ( A : : SHOOT_TIMER ) = ConfigFloat ( " Attack Windup Time " ) ;
m . PerformAnimation ( " SHOOT " , m . GetFacingDirectionToTarget ( game - > GetPlayer ( ) - > GetPos ( ) ) ) ;
@ -108,17 +109,23 @@ void Monster::STRATEGY::GOBLIN_BOW(Monster&m,float fElapsedTime,std::string stra
PrepareToShoot ( ) ;
}
} break ;
case WINDUP : {
case LOCKON : {
m . F ( A : : SHOOT_TIMER ) - = fElapsedTime ;
m . UpdateFacingDirection ( game - > GetPlayer ( ) - > GetPos ( ) ) ;
if ( m . F ( A : : SHOOT_TIMER ) < = 0 ) {
if ( m . F ( A : : SHOOT_TIMER ) < = ConfigFloat ( " Bow Steadying Time " ) ) {
geom2d : : line pointTowardsPlayer ( m . GetPos ( ) , game - > GetPlayer ( ) - > GetPos ( ) ) ;
vf2d extendedLine = pointTowardsPlayer . upoint ( 1.1f ) ;
CreateBullet ( Arrow ) ( m . GetPos ( ) , extendedLine , pointTowardsPlayer . vector ( ) . norm ( ) * ConfigFloat ( " Arrow Spd " ) , " goblin_arrow.png " , ConfigFloat ( " Arrow Hitbox Radius " ) , m . GetAttack ( ) , m . OnUpperLevel ( ) ) EndBullet ;
Arrow & arrow = static_cast < Arrow & > ( * BULLET_LIST . back ( ) ) ;
arrow . PointToBestTargetPath ( m . F ( A : : PERCEPTION_LEVEL ) ) ;
m . V ( A : : EXTENDED_LINE ) = extendedLine ;
Arrow tempArrow { m . GetPos ( ) , extendedLine , pointTowardsPlayer . vector ( ) . norm ( ) * ConfigFloat ( " Arrow Spd " ) , " goblin_arrow.png " , ConfigFloat ( " Arrow Hitbox Radius " ) , m . GetAttack ( ) , m . OnUpperLevel ( ) } ;
m . V ( A : : FIRE_VELOCITY ) = tempArrow . PointToBestTargetPath ( m . F ( A : : PERCEPTION_LEVEL ) ) ;
m . phase = WINDUP ;
}
} break ;
case WINDUP : {
m . F ( A : : SHOOT_TIMER ) - = fElapsedTime ;
if ( m . F ( A : : SHOOT_TIMER ) < = 0 ) {
m . F ( A : : ATTACK_COOLDOWN ) = 0.f ;
CreateBullet ( Arrow ) ( m . GetPos ( ) , m . V ( A : : EXTENDED_LINE ) , m . V ( A : : FIRE_VELOCITY ) , " goblin_arrow.png " , ConfigFloat ( " Arrow Hitbox Radius " ) , m . GetAttack ( ) , m . OnUpperLevel ( ) ) EndBullet ;
m . F ( A : : PERCEPTION_LEVEL ) = std : : min ( ConfigFloat ( " Maximum Perception Level " ) , m . F ( A : : PERCEPTION_LEVEL ) + ConfigFloat ( " Perception Level Increase " ) ) ;
m . PerformAnimation ( " IDLE " , m . GetFacingDirectionToTarget ( game - > GetPlayer ( ) - > GetPos ( ) ) ) ;
m . phase = MOVE ;