Frog behavior implemented.

This commit is contained in:
2024-01-13 17:20:13 -06:00
parent 62a2119ab2
commit e8d2ec9e9d
12 changed files with 76 additions and 27 deletions
+33 -16
View File
@@ -40,12 +40,15 @@ All rights reserved.
#include "AdventuresInLestoria.h"
#include "MonsterStrategyHelpers.h"
#include "util.h"
#include "BulletTypes.h"
INCLUDE_game
INCLUDE_BULLET_LIST
using A=Attribute;
void Monster::STRATEGY::FROG(Monster&m,float fElapsedTime,std::string strategy){
m.F(A::LOCKON_WAITTIME)=std::max(0.0f,m.F(A::LOCKON_WAITTIME)-fElapsedTime);
phase:
switch(m.I(A::PHASE)){
case 0:{ //Move towards phase.
@@ -55,6 +58,23 @@ void Monster::STRATEGY::FROG(Monster&m,float fElapsedTime,std::string strategy){
m.F(A::LOCKON_WAITTIME)=ConfigFloat("Lockon Wait Time");
m.V(A::LOCKON_POS)=game->GetPlayer()->GetPos();
float dirToPlayer=util::angleTo(m.GetPos(),m.V(A::LOCKON_POS));
#pragma region Face towards lockon direction
if(abs(dirToPlayer)<0.5f*PI){ //This sprite is supposed to be facing right (flipped)
m.facingDirection=RIGHT;
m.spriteRot=dirToPlayer;
}else{
m.facingDirection=LEFT;
if(dirToPlayer>0){
m.spriteRot=-PI+dirToPlayer;
}else{
m.spriteRot=PI+dirToPlayer;
}
}
#pragma endregion
goto phase;
}
float dirToPlayer=util::angleTo(m.GetPos(),m.target);
#pragma region Face towards target direction
if(abs(dirToPlayer)<0.5f*PI){ //This sprite is supposed to be facing right (flipped)
m.facingDirection=RIGHT;
m.spriteRot=dirToPlayer;
@@ -66,30 +86,27 @@ void Monster::STRATEGY::FROG(Monster&m,float fElapsedTime,std::string strategy){
m.spriteRot=PI+dirToPlayer;
}
}
goto phase;
}
float dirToPlayer=util::angleTo(m.GetPos(),m.target);
if(abs(dirToPlayer)<0.5f*PI){ //This sprite is supposed to be facing right (flipped)
m.facingDirection=RIGHT;
m.spriteRot=dirToPlayer;
}else{
m.facingDirection=LEFT;
if(dirToPlayer>0){
m.spriteRot=-PI+dirToPlayer;
}else{
m.spriteRot=PI+dirToPlayer;
}
}
#pragma endregion
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
m.PerformJumpAnimation();
}break;
case 1:{
m.F(A::LOCKON_WAITTIME)=std::max(0.0f,m.F(A::LOCKON_WAITTIME)-fElapsedTime);
if(m.F(A::LOCKON_WAITTIME)==0.0f){
m.I(A::PHASE)=0;
m.F(A::LOCKON_WAITTIME)=ConfigFloat("Attack Duration");
vf2d tongueMaxRangePos=geom2d::line<float>(m.GetPos(),m.V(A::LOCKON_POS)).upoint(ConfigFloat("Tongue Max Range")/ConfigFloat("Range"));
CreateBullet(FrogTongue)(m.pos,tongueMaxRangePos,ConfigFloat("Attack Duration"),m.GetAttack(),m.OnUpperLevel(),ConfigFloat("Tongue Knockback Strength"),false,ConfigPixel("Tongue Color"))EndBullet;
m.PerformShootAnimation();
m.I(A::PHASE)=2;
}
m.PerformIdleAnimation();
}break;
case 2:{
if(m.F(A::LOCKON_WAITTIME)==0.0f){
m.F(A::LOCKON_WAITTIME)=ConfigFloat("Attack Recovery Time");
m.I(A::PHASE)=0;
}
}break;
default:{
ERR(std::format("Unhandled phase {} for {} strategy!",m.I(A::PHASE),strategy));
}