@ -54,8 +54,20 @@ void Monster::STRATEGY::PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string
PREPARE_SHOOT ,
PREPARE_SHOOT ,
SHOOT_RELOAD ,
SHOOT_RELOAD ,
DRINK_RUM ,
DRINK_RUM ,
WINDUP ,
RECOVERY ,
} ;
} ;
enum AttackType {
STAB ,
SLASH
} ;
if ( ! m . B ( A : : INITIALIZED ) ) {
m . B ( A : : INITIALIZED ) = true ;
m . phase = INIT ;
}
switch ( m . phase ) {
switch ( m . phase ) {
case INIT : {
case INIT : {
m . F ( A : : TARGET_TIMER ) = ConfigFloat ( " Shooting Frequency " ) ;
m . F ( A : : TARGET_TIMER ) = ConfigFloat ( " Shooting Frequency " ) ;
@ -72,8 +84,6 @@ void Monster::STRATEGY::PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string
} break ;
} break ;
case MOVE : {
case MOVE : {
m . F ( A : : TARGET_TIMER ) - = fElapsedTime ;
m . F ( A : : TARGET_TIMER ) - = fElapsedTime ;
GOBLIN_DAGGER ( m , fElapsedTime , " Goblin Dagger " ) ;
if ( m . F ( A : : TARGET_TIMER ) < = 0.f ) {
if ( m . F ( A : : TARGET_TIMER ) < = 0.f ) {
const float diceRoll { util : : random ( 100 ) } ;
const float diceRoll { util : : random ( 100 ) } ;
if ( diceRoll < = ConfigFloat ( " Shooting Chance " ) ) {
if ( diceRoll < = ConfigFloat ( " Shooting Chance " ) ) {
@ -92,6 +102,26 @@ void Monster::STRATEGY::PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string
m . F ( A : : BREAK_TIME ) = m . GetCurrentAnimation ( ) . GetTotalAnimationDuration ( ) ;
m . F ( A : : BREAK_TIME ) = m . GetCurrentAnimation ( ) . GetTotalAnimationDuration ( ) ;
m . phase = DRINK_RUM ;
m . phase = DRINK_RUM ;
}
}
else {
float distToPlayer = m . GetDistanceFrom ( game - > GetPlayer ( ) - > GetPos ( ) ) ;
if ( distToPlayer > ConfigFloat ( " Attack Spacing " ) / 100.f * 24 ) {
RUN_TOWARDS ( m , fElapsedTime , " Run Towards " ) ;
} else {
m . phase = WINDUP ;
m . I ( A : : ATTACK_TYPE ) = util : : random ( ) % 2 ; //Choose randomly between stab or slash.
switch ( m . I ( A : : ATTACK_TYPE ) ) {
case STAB : {
m . F ( A : : CASTING_TIMER ) = ConfigFloat ( " Stab Windup Time " ) ;
m . PerformAnimation ( " STAB " , m . GetFacingDirectionToTarget ( game - > GetPlayer ( ) - > GetPos ( ) ) ) ;
} break ;
case SLASH : {
m . F ( A : : CASTING_TIMER ) = ConfigFloat ( " Slash Windup Time " ) ;
m . PerformAnimation ( " SLASH " , m . GetFacingDirectionToTarget ( game - > GetPlayer ( ) - > GetPos ( ) ) ) ;
} break ;
default : ERR ( std : : format ( " WARNING! Invalid Attack type {} provided. THIS SHOULD NOT BE HAPPENING! " , m . I ( A : : ATTACK_TYPE ) ) ) ;
}
}
}
} break ;
} break ;
case PREPARE_SHOOT : {
case PREPARE_SHOOT : {
m . F ( A : : SHOOT_TIMER ) - = fElapsedTime ;
m . F ( A : : SHOOT_TIMER ) - = fElapsedTime ;
@ -116,5 +146,33 @@ void Monster::STRATEGY::PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string
m . phase = MOVE ;
m . phase = MOVE ;
}
}
} break ;
} break ;
case WINDUP : {
m . F ( A : : CASTING_TIMER ) - = fElapsedTime ;
if ( m . F ( A : : CASTING_TIMER ) < = 0 ) {
m . phase = RECOVERY ;
switch ( m . I ( A : : ATTACK_TYPE ) ) {
case STAB : {
vf2d stabTarget = game - > GetPlayer ( ) - > GetPos ( ) ;
m . PerformAnimation ( " STABBING " , m . GetFacingDirectionToTarget ( game - > GetPlayer ( ) - > GetPos ( ) ) ) ;
CreateBullet ( DaggerStab ) ( m , ConfigString ( " Dagger Stab Image " ) , ConfigFloat ( " Dagger Hit Radius " ) , m . GetAttack ( ) , ConfigFloat ( " Dagger Stab Knockback " ) , m . OnUpperLevel ( ) , m . GetFacingDirectionToTarget ( stabTarget ) , ConfigFloat ( " Dagger Frame Duration " ) , ConfigFloat ( " Dagger Stab Distance " ) ,
DaggerStab : : DirectionOffsets { ConfigVec ( " Dagger Up Offset " ) , ConfigVec ( " Dagger Down Offset " ) , ConfigVec ( " Dagger Right Offset " ) , ConfigVec ( " Dagger Left Offset " ) } ) EndBullet ;
} break ;
case SLASH : {
vf2d slashTarget = game - > GetPlayer ( ) - > GetPos ( ) ;
m . PerformAnimation ( " SLASHING " , m . GetFacingDirectionToTarget ( game - > GetPlayer ( ) - > GetPos ( ) ) ) ;
CreateBullet ( DaggerSlash ) ( m , ConfigString ( " Dagger Slash Image " ) , ConfigFloat ( " Dagger Hit Radius " ) , m . GetAttack ( ) , ConfigFloat ( " Dagger Slash Knockback " ) , m . OnUpperLevel ( ) , m . GetFacingDirectionToTarget ( slashTarget ) , ConfigFloat ( " Dagger Frame Duration " ) , ConfigFloat ( " Dagger Slash Distance " ) ) EndBullet ;
} break ;
default : ERR ( std : : format ( " WARNING! Invalid Attack type {} provided. THIS SHOULD NOT BE HAPPENING! " , m . I ( A : : ATTACK_TYPE ) ) ) ;
}
m . F ( A : : CASTING_TIMER ) = m . GetCurrentAnimation ( ) . GetTotalAnimationDuration ( ) ;
m . F ( A : : RECOVERY_TIME ) = ConfigFloat ( " Attack Recovery Time " ) ;
}
} break ;
case RECOVERY : {
m . F ( A : : CASTING_TIMER ) - = fElapsedTime ;
m . F ( A : : RECOVERY_TIME ) - = fElapsedTime ;
if ( m . F ( A : : CASTING_TIMER ) < = 0 ) { m . PerformIdleAnimation ( m . GetFacingDirectionToTarget ( game - > GetPlayer ( ) - > GetPos ( ) ) ) ; }
if ( m . F ( A : : RECOVERY_TIME ) < = 0 ) m . phase = MOVE ;
} break ;
}
}
}
}