From 1bb87eab233952fe80f8e64cabc8f0219ba95677 Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Sat, 23 Sep 2023 17:35:37 +0000 Subject: [PATCH] Extra implementations in phase 2 Co-authored-by: sigonasr2 --- Crawler/Monster.cpp | 35 --------------------- Crawler/MonsterAttribute.h | 3 ++ Crawler/SlimeKing.cpp | 26 ++++++++++----- Crawler/assets/config/MonsterStrategies.txt | 8 ++--- 4 files changed, 25 insertions(+), 47 deletions(-) diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp index 9a23eb88..b9d73218 100644 --- a/Crawler/Monster.cpp +++ b/Crawler/Monster.cpp @@ -386,41 +386,6 @@ 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 9b896196..eccfcd5b 100644 --- a/Crawler/MonsterAttribute.h +++ b/Crawler/MonsterAttribute.h @@ -22,4 +22,7 @@ enum class Attribute{ RECOVERY_TIME, SHOOT_ANIMATION_TIME, SHOOT_TIMER, + JUMP_MOVE_SPD, + JUMP_COUNT, + CASTING_TIMER, }; \ No newline at end of file diff --git a/Crawler/SlimeKing.cpp b/Crawler/SlimeKing.cpp index 5b7b8efe..c1804b5a 100644 --- a/Crawler/SlimeKing.cpp +++ b/Crawler/SlimeKing.cpp @@ -23,6 +23,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe m.F(A::SHOOT_RING_TIMER)=std::max(0.f,m.F(A::SHOOT_RING_TIMER)-fElapsedTime); m.F(A::SHOOT_RING_DELAY)=std::max(0.f,m.F(A::SHOOT_RING_DELAY)-fElapsedTime); m.F(A::JUMP_LANDING_TIMER)=std::max(0.f,m.F(A::JUMP_LANDING_TIMER)-fElapsedTime); + m.F(A::CASTING_TIMER)=std::max(0.f,m.F(A::CASTING_TIMER)-fElapsedTime); const auto ShootBulletRing=[&](float angleOffset){ int bulletCount=ConfigInt("Phase1.RingBulletCount"); @@ -47,7 +48,6 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe const auto SpawnMonsterFromConfig=[&](int phase){ std::string spawnMonster=ConfigStringArr("Phase"+std::to_string(phase)+".MonsterSpawnOnChange",0); int spawnCount=ConfigIntArr("Phase"+std::to_string(phase)+".MonsterSpawnOnChange",1); - for(int i=0;igame->GetPlayer()->GetPos().x){ m.SetX(std::max(game->GetPlayer()->GetPos().x,m.GetPos().x-ConfigInt("JumpMoveSpd")*game->GetElapsedTime())); @@ -139,8 +140,15 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe return; } - if(m.state==State::CASTING){ + if(m.GetState()==State::CASTING){ m.UpdateAnimation("monsters/Slime King - Cast.png"); + 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); + StartJump(jumpTime,game->GetPlayer()->GetPos(),0.2,jumpSpd); + } return; } @@ -161,7 +169,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe } if(m.F(A::SHOOT_RING_TIMER)==0){ if(m.I(A::PATTERN_REPEAT_COUNT)>=ConfigInt("Phase1.JumpAfter")){ - StartJump(ConfigFloat("Phase1.AirborneTime"),game->GetPlayer()->GetPos(),ConfigFloat("Phase1.LandingRecoveryTime")); + StartJump(ConfigFloat("Phase1.AirborneTime"),game->GetPlayer()->GetPos(),ConfigFloat("Phase1.LandingRecoveryTime"),ConfigFloat("JumpMoveSpd")); m.I(A::PATTERN_REPEAT_COUNT)=0; return; } @@ -204,6 +212,8 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe } if(m.I(A::PATTERN_REPEAT_COUNT)>ConfigInt("Phase2.ShootCount")){ m.I(A::PATTERN_REPEAT_COUNT)=0; + m.I(A::JUMP_COUNT)=0; + m.F(A::CASTING_TIMER)=5; m.SetState(State::CASTING); } }break; diff --git a/Crawler/assets/config/MonsterStrategies.txt b/Crawler/assets/config/MonsterStrategies.txt index 2cf3b4aa..2b81e5bf 100644 --- a/Crawler/assets/config/MonsterStrategies.txt +++ b/Crawler/assets/config/MonsterStrategies.txt @@ -115,10 +115,10 @@ MonsterStrategy JumpChargeTime = 5.0 JumpAfter = 5 shots JumpCount = 3 - # Delay times per jump in seconds. - Jump[1] = 2.0 - Jump[2] = 0.3 - Jump[3] = 0.75 + # 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 } Phase3 {