Tuned jump delays and values for phase 2.

This commit is contained in:
2023-09-23 13:12:00 -05:00
parent 1bb87eab23
commit cf782c29bb
6 changed files with 83 additions and 15 deletions
+37 -8
View File
@@ -74,19 +74,42 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
}
};
const auto StartJump=[&](float jumpDuration,vf2d targetPos,float recoveryTime,float jumpMoveSpd){
const auto StartJump=[&](float jumpDuration,vf2d targetPos,float recoveryTime,float jumpMoveSpd,bool teleportToPlayer=false){
m.V(A::JUMP_ORIGINAL_POS)=m.GetPos();
m.F(A::JUMP_ORIGINAL_LANDING_TIMER)=m.F(A::JUMP_LANDING_TIMER)=jumpDuration;
m.V(A::JUMP_TARGET_POS)=targetPos;
m.F(A::RECOVERY_TIME)=recoveryTime;
m.F(A::JUMP_MOVE_SPD)=jumpMoveSpd;
m.B(A::TELEPORT_TO_PLAYER)=teleportToPlayer;
m.SetState(State::JUMP);
};
const auto Recovered=[&](){
switch(m.phase){
case 2:{
switch(m.I(A::JUMP_COUNT)){
case 1:
case 2:{ //After the 1st and 2nd jumps we still have another jump to accomplish.
m.I(A::JUMP_COUNT)++;
float jumpTime=ConfigFloatArr("Phase2.Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",0);
float jumpSpd=ConfigFloatArr("Phase2.Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",1);
bool jumpTeleport=bool(ConfigIntArr("Phase2.Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",2));
StartJump(jumpTime,game->GetPlayer()->GetPos(),0.2,jumpSpd,jumpTeleport);
}break;
default:{
m.PerformIdleAnimation();
m.SetState(State::NORMAL);
}
}
}break;
}
};
if(m.GetState()==State::RECOVERY){
m.F(A::RECOVERY_TIME)=std::max(0.f,m.F(A::RECOVERY_TIME)-fElapsedTime);
if(m.F(A::RECOVERY_TIME)==0){
m.GetState()==State::NORMAL;
Recovered();
}
return;
}
@@ -94,16 +117,16 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
if(m.GetState()==State::JUMP){
float jumpLandingTimerRatio=m.F(A::JUMP_LANDING_TIMER)/m.F(A::JUMP_ORIGINAL_LANDING_TIMER);
if(m.GetPos().x>game->GetPlayer()->GetPos().x){
m.SetX(std::max(game->GetPlayer()->GetPos().x,m.GetPos().x-ConfigInt("JumpMoveSpd")*game->GetElapsedTime()));
m.SetX(std::max(game->GetPlayer()->GetPos().x,m.GetPos().x-m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
} else
if(m.GetPos().x<game->GetPlayer()->GetPos().x){
m.SetX(std::min(game->GetPlayer()->GetPos().x,m.GetPos().x+ConfigInt("JumpMoveSpd")*game->GetElapsedTime()));
m.SetX(std::min(game->GetPlayer()->GetPos().x,m.GetPos().x+m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
}
if(m.GetPos().y>game->GetPlayer()->GetPos().y){
m.SetY(std::max(game->GetPlayer()->GetPos().y,m.GetPos().y-ConfigInt("JumpMoveSpd")*game->GetElapsedTime()));
m.SetY(std::max(game->GetPlayer()->GetPos().y,m.GetPos().y-m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
} else
if(m.GetPos().y<game->GetPlayer()->GetPos().y){
m.SetY(std::min(game->GetPlayer()->GetPos().y,m.GetPos().y+ConfigInt("JumpMoveSpd")*game->GetElapsedTime()));
m.SetY(std::min(game->GetPlayer()->GetPos().y,m.GetPos().y+m.F(A::JUMP_MOVE_SPD)*game->GetElapsedTime()));
}
if(m.F(A::JUMP_LANDING_TIMER)>=m.F(A::JUMP_ORIGINAL_LANDING_TIMER)/2){
m.SetZ(util::lerp(0,ConfigInt("JumpHeight"),1-jumpLandingTimerRatio));
@@ -126,12 +149,18 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
lineToPlayer={m.GetPos(),m.GetPos()+vf2d{cos(randomDir),sin(randomDir)}*1};
}
game->GetPlayer()->Knockback(lineToPlayer.vector().norm()*ConfigInt("JumpKnockbackFactor"));
game->GetPlayer()->SetIframes(1);
if(m.phase!=2){ //In phase 2, the player can get slammed multiple times. No iframes for messing up.
game->GetPlayer()->SetIframes(1);
}
}
Landed(m.phase);
m.SetStrategyDrawFunction([](Crawler*game){});
} else
if(m.F(A::JUMP_LANDING_TIMER)<=ConfigFloat("JumpWarningIndicatorTime")){
if(m.B(A::TELEPORT_TO_PLAYER)){
m.B(A::TELEPORT_TO_PLAYER)=false;
m.SetPos(game->GetPlayer()->GetPos());
}
m.SetStrategyDrawFunction([&](Crawler*game){
Decal*dec=ANIMATION_DATA["range_indicator.png"].GetFrame(game->GetElapsedTime()).GetSourceImage()->Decal();
game->view.DrawRotatedDecal(m.GetPos(),dec,0,dec->sprite->Size()/2,vf2d{m.GetSizeMult(),m.GetSizeMult()},RED);
@@ -145,8 +174,8 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe
if(m.F(A::CASTING_TIMER)==0){
m.SetState(State::NORMAL);
m.I(A::JUMP_COUNT)++;
float jumpTime=ConfigFloatArr("Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",0);
float jumpSpd=ConfigFloatArr("Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",1);
float jumpTime=ConfigFloatArr("Phase2.Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",0);
float jumpSpd=ConfigFloatArr("Phase2.Jump["+std::to_string(m.I(A::JUMP_COUNT))+"]",1);
StartJump(jumpTime,game->GetPlayer()->GetPos(),0.2,jumpSpd);
}
return;