@ -51,20 +51,74 @@ using A=Attribute;
void Monster : : STRATEGY : : WOLF ( Monster & m , float fElapsedTime , std : : string strategy ) {
switch ( m . I ( A : : PHASE ) ) {
case 0 : { //Run towards the player.
float distToPlayer = geom2d : : line < float > ( game - > GetPlayer ( ) - > GetPos ( ) , m . GetPos ( ) ) . length ( ) ;
if ( distToPlayer < = ConfigFloat ( " Lockon Range " ) ) {
float distToPlayer = geom2d : : line < float > ( game - > GetPlayer ( ) - > GetPos ( ) , m . GetPos ( ) ) . length ( ) ;
if ( distToPlayer < = ConfigFloat ( " Lockon Range " ) / 100 * 24.f ) {
m . I ( A : : PHASE ) = 1 ;
m . V ( A : : LOCKON_POS ) = game - > GetPlayer ( ) - > GetPos ( ) ;
m . AddBuff ( BuffType : : )
m . V ( A : : LOCKON_POS ) = geom2d : : line < float > ( m . GetPos ( ) , game - > GetPlayer ( ) - > GetPos ( ) ) . upoint ( 1.2f ) ;
m . AddBuff ( BuffType : : LOCKON_SPEEDBOOST , INFINITE , ConfigFloat ( " Lockon Speed Boost " ) / 100 ) ;
m . F ( A : : TARGET_TIMER ) = 5.0f ;
}
m . target = game - > GetPlayer ( ) - > GetPos ( ) ;
RUN_TOWARDS ( m , fElapsedTime , " Run Towards " ) ;
} break ;
case 1 : { //Charge the player.
m . F ( A : : TARGET_TIMER ) = std : : max ( 0.f , m . F ( A : : TARGET_TIMER ) - fElapsedTime ) ;
float distToTarget = geom2d : : line < float > ( m . GetPos ( ) , m . V ( A : : LOCKON_POS ) ) . length ( ) ;
if ( distToTarget < = 12.f | | m . F ( A : : TARGET_TIMER ) = = 0.f ) {
m . I ( A : : PHASE ) = 2 ;
m . F ( A : : RECOVERY_TIME ) = ConfigFloat ( " Charge Recovery Time " ) ;
m . PerformIdleAnimation ( ) ;
} else {
m . target = m . V ( A : : LOCKON_POS ) ;
RUN_TOWARDS ( m , fElapsedTime , " Run Towards " ) ;
}
} break ;
case 2 : { //Recovery period after charging.
m . F ( A : : RECOVERY_TIME ) = std : : max ( 0.f , m . F ( A : : RECOVERY_TIME ) - fElapsedTime ) ;
if ( m . F ( A : : RECOVERY_TIME ) = = 0.f ) {
m . RemoveBuff ( BuffType : : LOCKON_SPEEDBOOST ) ;
m . AddBuff ( BuffType : : SPEEDBOOST , ConfigFloatArr ( " Disengage Speed Boost " , 1 ) , ConfigFloatArr ( " Disengage Speed Boost " , 0 ) / 100 ) ;
std : : vector < vf2d > disengagePoints ;
for ( float angle = 0.f ; angle < 360.f ; angle + = 22.5f ) {
float range = 50 ;
vf2d checkLoc = vf2d { 0 , util : : degToRad ( angle ) } . cart ( ) ;
while ( range < = ConfigFloat ( " Disengage Range " ) ) {
checkLoc = game - > GetPlayer ( ) - > GetPos ( ) + vf2d { range / 100 * 24.f , util : : degToRad ( angle ) } . cart ( ) ;
if ( game - > GetTileCollision ( game - > GetCurrentMapName ( ) , checkLoc , m . OnUpperLevel ( ) ) ! = game - > NO_COLLISION ) {
break ;
}
range + = 50 ;
}
disengagePoints . push_back ( checkLoc ) ;
}
m . path . Initialize ( disengagePoints ) ;
if ( disengagePoints . size ( ) ! = 16 ) ERR ( std : : format ( " Disengage Points size was not equal to 16! Size: {} " , disengagePoints . size ( ) ) ) ;
if ( m . path . points . size ( ) ! = 16 ) ERR ( std : : format ( " Path Points size was not equal to 16! Size: {} " , m . path . points . size ( ) ) ) ;
m . I ( A : : PATH_DIR ) = util : : random ( ) % 2 ;
if ( m . I ( A : : PATH_DIR ) = = 0 ) m . I ( A : : PATH_DIR ) = - 1 ;
m . pathIndex = util : : random ( ) % disengagePoints . size ( ) ;
m . I ( A : : PHASE ) = 3 ;
m . F ( A : : RUN_AWAY_TIMER ) = ConfigFloat ( " Disengage Duration " ) ;
m . PerformJumpAnimation ( ) ;
}
} break ;
case 3 : {
case 3 : { //Disengage.
m . F ( A : : RUN_AWAY_TIMER ) = std : : max ( 0.f , m . F ( A : : RUN_AWAY_TIMER ) - fElapsedTime ) ;
m . pathIndex + = m . I ( A : : PATH_DIR ) * fElapsedTime * 1.25f ;
m . pathIndex = fmod ( m . pathIndex , m . path . points . size ( ) ) ;
if ( m . pathIndex < 0 ) { //When the modulus is negative, adding the total number of elements gets us to the correct index.
m . pathIndex = m . pathIndex + m . path . points . size ( ) ;
}
if ( m . F ( A : : RUN_AWAY_TIMER ) = = 0.f ) {
m . I ( A : : PHASE ) = 0 ;
}
m . target = m . path . GetSplinePoint ( m . pathIndex ) . pos ;
geom2d : : line < float > moveTowardsLine = geom2d : : line ( m . pos , m . path . GetSplinePoint ( m . pathIndex ) . pos ) ;
if ( moveTowardsLine . length ( ) > 4.f ) {
m . UpdateFacingDirection ( moveTowardsLine . end ) ;
}
m . SetPos ( m . pos + moveTowardsLine . vector ( ) . norm ( ) * 100 * fElapsedTime * m . GetMoveSpdMult ( ) ) ;
} break ;
}
}