Move Attack Arc function into its own function for portability.

master
sigonasr2 3 weeks ago
parent 46ba7a780d
commit 16708108e6
  1. 50
      Adventures in Lestoria/OctopusArm.cpp
  2. 2
      Adventures in Lestoria/assets/config/MonsterStrategies.txt

@ -54,6 +54,26 @@ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string str
SEARCH, SEARCH,
PREPARE_ATTACK, PREPARE_ATTACK,
}; };
const auto GetAttackArc=[](const Monster&m){
float arcAngle{};
switch(m.GetFacingDirection()){
case Direction::NORTH:{
arcAngle=-PI/2;
}break;
case Direction::EAST:{
arcAngle=0.f;
}break;
case Direction::WEST:{
arcAngle=PI;
}break;
case Direction::SOUTH:{
arcAngle=PI/2;
}break;
}
return Arc{m.GetPos(),"Attack Radius"_F/100.f*24,arcAngle,util::degToRad("Attack Arc"_F)};
};
switch(PHASE()){ switch(PHASE()){
case INIT:{ case INIT:{
m.PerformAnimation("RISE",game->GetPlayer()->GetPos()); m.PerformAnimation("RISE",game->GetPlayer()->GetPos());
@ -72,31 +92,25 @@ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string str
SETPHASE(PREPARE_ATTACK); SETPHASE(PREPARE_ATTACK);
m.F(A::ATTACK_COOLDOWN)="Attack Wiggle Time Range"_FRange; m.F(A::ATTACK_COOLDOWN)="Attack Wiggle Time Range"_FRange;
m.PerformAnimation("ATTACKING",game->GetPlayer()->GetPos()); m.PerformAnimation("ATTACKING",game->GetPlayer()->GetPos());
float arcAngle{};
switch(m.GetFacingDirection()){ Arc attackArc{GetAttackArc(m)};
case Direction::NORTH:{
arcAngle=-PI/2;
}break;
case Direction::EAST:{
arcAngle=0.f;
}break;
case Direction::WEST:{
arcAngle=PI;
}break;
case Direction::SOUTH:{
arcAngle=PI/2;
}break;
}
Arc attackArc{m.GetPos(),"Attack Radius"_F/100.f*24,arcAngle,util::degToRad("Attack Arc"_F)};
m.SetStrategyDrawFunction([&attackArc](AiL*game,Monster&monster,const std::string&strategy){ m.SetStrategyDrawFunction([&attackArc](AiL*game,Monster&monster,const std::string&strategy){
attackArc.Draw(game,BLUE); const float alphaTimer{std::fmod(game->GetRunTime(),2.f)};
uint8_t alpha{util::lerp(0,255,alphaTimer)};
if(alphaTimer>1.f)alpha=util::lerp(0,255,1-(alphaTimer-1));
attackArc.Draw(game,{0,0,255,uint8_t(alpha)});
}); });
} }
}break; }break;
case PREPARE_ATTACK:{ case PREPARE_ATTACK:{
m.F(A::ATTACK_COOLDOWN)-=fElapsedTime; m.F(A::ATTACK_COOLDOWN)-=fElapsedTime;
if(m.F(A::ATTACK_COOLDOWN)<=0.f){ if(m.F(A::ATTACK_COOLDOWN)<=0.f){
Arc attackArc{GetAttackArc(m)};
if(attackArc.overlaps(game->GetPlayer()->GetPos())){
game->GetPlayer()->Knockback(util::pointTo(m.GetPos(),game->GetPlayer()->GetPos())*"Attack Knockback"_F);
game->GetPlayer()->Hurt(m.GetAttack(),m.OnUpperLevel(),m.GetZ());
}
} }
}break; }break;
} }

@ -1207,5 +1207,7 @@ MonsterStrategy
Attack Wiggle Time Range = 2s,4s Attack Wiggle Time Range = 2s,4s
Attack Arc = 60deg Attack Arc = 60deg
Attack Wait Time = 1s Attack Wait Time = 1s
Attack Knockback = 50
} }
} }
Loading…
Cancel
Save