diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp index b9d73218..59840e13 100644 --- a/Crawler/Monster.cpp +++ b/Crawler/Monster.cpp @@ -386,6 +386,41 @@ void Monster::SetSize(float newSize,bool immediate){ } } +float&Monster::GetFloat(Attribute a){ + if(attributes.count(a)==0){ + attributes[a]=0.f; + } + return std::get(attributes[a]); +} + +int&Monster::GetInt(Attribute a){ + if(attributes.count(a)==0){ + attributes[a]=0; + } + return std::get(attributes[a]); +} + +std::string&Monster::GetString(Attribute a){ + if(attributes.count(a)==0){ + attributes[a]=""; + } + return std::get(attributes[a]); +} + +bool&Monster::GetBool(Attribute a){ + if(attributes.count(a)==0){ + attributes[a]=false; + } + return std::get(attributes[a]); +} + +vf2d&Monster::GetVf2d(Attribute a){ + if(attributes.count(a)==0){ + attributes[a]=vf2d{}; + } + return std::get(attributes[a]); +} + void Monster::SetZ(float z){ this->z=z; } diff --git a/Crawler/MonsterAttribute.h b/Crawler/MonsterAttribute.h index eccfcd5b..f9699834 100644 --- a/Crawler/MonsterAttribute.h +++ b/Crawler/MonsterAttribute.h @@ -25,4 +25,5 @@ enum class Attribute{ JUMP_MOVE_SPD, JUMP_COUNT, CASTING_TIMER, + TELEPORT_TO_PLAYER, }; \ No newline at end of file diff --git a/Crawler/SlimeKing.cpp b/Crawler/SlimeKing.cpp index c1804b5a..74bb8ec3 100644 --- a/Crawler/SlimeKing.cpp +++ b/Crawler/SlimeKing.cpp @@ -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().xGetPlayer()->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().yGetPlayer()->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; diff --git a/Crawler/Version.h b/Crawler/Version.h index c52600d5..5e6b71af 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 1372 +#define VERSION_BUILD 1383 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/config/MonsterStrategies.txt b/Crawler/assets/config/MonsterStrategies.txt index 2b81e5bf..bf4c1d2a 100644 --- a/Crawler/assets/config/MonsterStrategies.txt +++ b/Crawler/assets/config/MonsterStrategies.txt @@ -79,7 +79,7 @@ MonsterStrategy # How much time a jump will be pre-telegraphed. JumpWarningIndicatorTime = 1.0 # Distance to jump up into the sky. A higher value causes it to launch up and down seemingly faster. - JumpHeight = 2400 + JumpHeight = 900 ProjectileDamage = 10 JumpAttackDamage = 20 JumpMoveSpd = 75 @@ -115,10 +115,13 @@ MonsterStrategy JumpChargeTime = 5.0 JumpAfter = 5 shots JumpCount = 3 - # Delay times per jump in seconds followed by the move speeds. - Jump[1] = 2.0, 75 - Jump[2] = 0.3, 120 - Jump[3] = 0.75, 75 + + # Argument 0 is jump time. + # Argument 1 is move speed. + # Argument 2 is whether to teleport to the player or not (0=Don't Teleport, 1=Teleport) + Jump[1] = 2.0, 75, 0 + Jump[2] = 0.3, 300, 1 + Jump[3] = 1.2, 70, 0 } Phase3 { diff --git a/Crawler/assets/config/configuration.txt b/Crawler/assets/config/configuration.txt index e9836f34..0f8cd003 100644 --- a/Crawler/assets/config/configuration.txt +++ b/Crawler/assets/config/configuration.txt @@ -10,7 +10,7 @@ gfx_config = gfx/gfx.txt map_config = levels.txt # Starting map when loading the game. -starting_map = CAMPAIGN_1_1 +starting_map = BOSS_1 # Player Properties Loading Config player_config = Player.txt