From a69be08a1a050080cc75ee60715a20d6d1d04923 Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Thu, 7 Sep 2023 20:20:21 +0000 Subject: [PATCH] Size reduction on slime king per phase. Add in size transition amounts based on time. Co-authored-by: sigonasr2 --- Crawler/Crawler.cpp | 2 ++ Crawler/Crawler.h | 1 + Crawler/Monster.cpp | 18 +++++++++++++++++- Crawler/Monster.h | 2 ++ Crawler/SlimeKing.cpp | 3 +++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 1e5a931a..8ea81b33 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -35,6 +35,8 @@ Key Crawler::KEY_ABILITY2=E; Key Crawler::KEY_ABILITY3=R; Key Crawler::KEY_ABILITY4=F; +float Crawler::SIZE_CHANGE_SPEED=1; + Crawler::Crawler() { sAppName = "Crawler Concept"; diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index dd992cc1..02d091f8 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -37,6 +37,7 @@ public: static Key KEY_ABILITY2; static Key KEY_ABILITY3; static Key KEY_ABILITY4; + static float SIZE_CHANGE_SPEED; private: std::vector>foregroundEffects,backgroundEffects,foregroundEffectsToBeInserted,backgroundEffectsToBeInserted; std::mapMAP_DATA; diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp index 4557e090..01723f10 100644 --- a/Crawler/Monster.cpp +++ b/Crawler/Monster.cpp @@ -20,7 +20,7 @@ safemapSTRATEGY_ID_DATA; std::mapMonsterData::imgs; Monster::Monster(vf2d pos,MonsterData data,bool upperLevel): - pos(pos),hp(data.GetHealth()),maxhp(data.GetHealth()),atk(data.GetAttack()),moveSpd(data.GetMoveSpdMult()),size(data.GetSizeMult()),strategy(data.GetAIStrategy()),id(data.GetID()),upperLevel(upperLevel){ + pos(pos),hp(data.GetHealth()),maxhp(data.GetHealth()),atk(data.GetAttack()),moveSpd(data.GetMoveSpdMult()),size(data.GetSizeMult()),targetSize(data.GetSizeMult()),strategy(data.GetAIStrategy()),id(data.GetID()),upperLevel(upperLevel){ bool firstAnimation=true; for(std::string&anim:data.GetAnimations()){ animation.AddState(anim,ANIMATION_DATA[anim]); @@ -110,6 +110,13 @@ bool Monster::SetY(float y){ bool Monster::Update(float fElapsedTime){ lastHitTimer=std::max(0.f,lastHitTimer-fElapsedTime); iframe_timer=std::max(0.f,iframe_timer-fElapsedTime); + if(size!=targetSize){ + if(size>targetSize){ + size=std::max(targetSize,size-Crawler::SIZE_CHANGE_SPEED*fElapsedTime); + }else{ + size=std::min(targetSize,size+Crawler::SIZE_CHANGE_SPEED*fElapsedTime); + } + } if(IsAlive()){ for(std::vector::iterator it=buffList.begin();it!=buffList.end();++it){ Buff&b=*it; @@ -273,6 +280,7 @@ vf2d MonsterSpawner::GetRange(){ vf2d MonsterSpawner::GetPos(){ return pos; } + void MonsterSpawner::SetTriggered(bool trigger,bool spawnMonsters){ triggered=trigger; if(spawnMonsters){ @@ -365,4 +373,12 @@ float Monster::GetZ(){ std::string Monster::GetStrategy(){ return STRATEGY_ID_DATA[strategy]; +} + +void Monster::SetSize(float newSize,bool immediate){ + if(immediate){ + size=targetSize=newSize; + }else{ + targetSize=newSize; + } } \ No newline at end of file diff --git a/Crawler/Monster.h b/Crawler/Monster.h index 7de390ca..0d38e940 100644 --- a/Crawler/Monster.h +++ b/Crawler/Monster.h @@ -88,6 +88,7 @@ private: int phase=0; bool diesNormally=true; //If set to false, the monster death is handled in a special way. Set it to true when it's time to die. float iframeTimeUponHit=0; + float targetSize=0; protected: public: Monster()=delete; @@ -132,6 +133,7 @@ public: bool HasIframes(); float GetZ(); std::string GetStrategy(); + void SetSize(float newSize,bool immediate=true); private: struct STRATEGY{ static int _GetInt(Monster&m,std::string param,int strategyNumber,int index=0); diff --git a/Crawler/SlimeKing.cpp b/Crawler/SlimeKing.cpp index 09ba1145..153f9a52 100644 --- a/Crawler/SlimeKing.cpp +++ b/Crawler/SlimeKing.cpp @@ -18,16 +18,19 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe case 1:{ if(m.hp<=m.maxhp*ConfigFloat("Phase2.Change")/100){ m.phase=2; + m.SetSize(ConfigFloat("Phase2.Size")/100,false); } }break; case 2:{ if(m.hp<=m.maxhp*ConfigFloat("Phase3.Change")/100){ m.phase=3; + m.SetSize(ConfigFloat("Phase3.Size")/100,false); } }break; case 3:{ if(m.hp<=m.maxhp*ConfigFloat("Phase4.Change")/100){ m.phase=4; + m.SetSize(ConfigFloat("Phase4.Size")/100,false); } }break; case 4:{