diff --git a/Adventures in Lestoria/OctopusArm.cpp b/Adventures in Lestoria/OctopusArm.cpp index bf3d9971..c2577d93 100644 --- a/Adventures in Lestoria/OctopusArm.cpp +++ b/Adventures in Lestoria/OctopusArm.cpp @@ -54,6 +54,26 @@ void Monster::STRATEGY::OCTOPUS_ARM(Monster&m,float fElapsedTime,std::string str SEARCH, 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()){ case INIT:{ 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); m.F(A::ATTACK_COOLDOWN)="Attack Wiggle Time Range"_FRange; m.PerformAnimation("ATTACKING",game->GetPlayer()->GetPos()); - 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; - } - Arc attackArc{m.GetPos(),"Attack Radius"_F/100.f*24,arcAngle,util::degToRad("Attack Arc"_F)}; + + Arc attackArc{GetAttackArc(m)}; + 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; case PREPARE_ATTACK:{ m.F(A::ATTACK_COOLDOWN)-=fElapsedTime; 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; } diff --git a/Adventures in Lestoria/assets/config/MonsterStrategies.txt b/Adventures in Lestoria/assets/config/MonsterStrategies.txt index d6a68c09..df9e822f 100644 --- a/Adventures in Lestoria/assets/config/MonsterStrategies.txt +++ b/Adventures in Lestoria/assets/config/MonsterStrategies.txt @@ -1207,5 +1207,7 @@ MonsterStrategy Attack Wiggle Time Range = 2s,4s Attack Arc = 60deg Attack Wait Time = 1s + + Attack Knockback = 50 } } \ No newline at end of file