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