|
|
|
@ -50,15 +50,61 @@ void Monster::STRATEGY::PIRATE_CAPTAIN(Monster&m,float fElapsedTime,std::string |
|
|
|
|
enum PhaseName{ |
|
|
|
|
INIT, |
|
|
|
|
MOVE, |
|
|
|
|
PREPARE_SHOOT, |
|
|
|
|
SHOOT_RELOAD, |
|
|
|
|
DRINK_RUM, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
switch(m.phase){ |
|
|
|
|
case INIT:{ |
|
|
|
|
m.F(A::TARGET_TIMER)= |
|
|
|
|
m.F(A::TARGET_TIMER)=ConfigFloat("Shooting Frequency"); |
|
|
|
|
m.phase=MOVE; |
|
|
|
|
}break; |
|
|
|
|
case MOVE:{ |
|
|
|
|
m.F(A::TARGET_TIMER)-=fElapsedTime; |
|
|
|
|
GOBLIN_DAGGER(m,fElapsedTime,"Goblin Dagger"); |
|
|
|
|
|
|
|
|
|
if(m.F(A::TARGET_TIMER)<=0.f){ |
|
|
|
|
const float diceRoll{util::random(100)}; |
|
|
|
|
if(diceRoll<=ConfigFloat("Shooting Chance")){ |
|
|
|
|
const float distToPlayer{util::distance(game->GetPlayer()->GetPos(),m.GetPos())}; |
|
|
|
|
if(distToPlayer<=ConfigFloat("Shoot Max Range")/100.f*24){ |
|
|
|
|
m.F(A::SHOOT_TIMER)=ConfigFloat("Shooting Delay"); |
|
|
|
|
m.phase=PREPARE_SHOOT; |
|
|
|
|
m.PerformAnimation("SHOOT",game->GetPlayer()->GetPos()); |
|
|
|
|
m.V(A::LOCKON_POS)=game->GetPlayer()->GetPos(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
m.F(A::TARGET_TIMER)=ConfigFloat("Shooting Frequency"); |
|
|
|
|
}else |
|
|
|
|
if(m.GetHealth()<ConfigInt("Rum Drink Threshold")){ |
|
|
|
|
m.PerformAnimation("DRINK"); |
|
|
|
|
m.F(A::BREAK_TIME)=m.GetCurrentAnimation().GetTotalAnimationDuration(); |
|
|
|
|
m.phase=DRINK_RUM; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case PREPARE_SHOOT:{ |
|
|
|
|
m.F(A::SHOOT_TIMER)-=fElapsedTime; |
|
|
|
|
if(m.F(A::SHOOT_TIMER)<=0.f){ |
|
|
|
|
CreateBullet(Bullet)(m.GetPos(),util::pointTo(m.GetPos(),m.V(A::LOCKON_POS))*ConfigFloat("Bullet Speed"),ConfigFloat("Bullet Radius"),m.GetAttack(),m.OnUpperLevel(),false,ConfigPixel("Bullet Color"),vf2d{1.f,1.f}*ConfigFloat("Bullet Radius")/3.f)EndBullet; |
|
|
|
|
m.PerformAnimation("SHOOTING"); |
|
|
|
|
m.F(A::SHOOT_ANIMATION_TIME)=m.GetCurrentAnimation().GetTotalAnimationDuration(); |
|
|
|
|
m.phase=SHOOT_RELOAD; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case SHOOT_RELOAD:{ |
|
|
|
|
m.F(A::SHOOT_ANIMATION_TIME)-=fElapsedTime; |
|
|
|
|
if(m.F(A::SHOOT_ANIMATION_TIME)<=0.f){ |
|
|
|
|
m.PerformAnimation("IDLE"); |
|
|
|
|
m.phase=MOVE; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case DRINK_RUM:{ |
|
|
|
|
m.F(A::BREAK_TIME)-=fElapsedTime; |
|
|
|
|
if(m.F(A::BREAK_TIME)<=0.f){ |
|
|
|
|
m.Heal(ConfigInt("Rum Health Recovery"),true); |
|
|
|
|
m.phase=MOVE; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
} |