diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 937e6394..1705ca68 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -121,6 +121,10 @@ bool Crawler::OnUserUpdate(float fElapsedTime){ for(Monster&m:MONSTER_LIST){ m.Update(fElapsedTime); } + for(Monster&m:monstersToBeSpawned){ + MONSTER_LIST.push_back(m); + } + monstersToBeSpawned.clear(); UpdateBullets(fElapsedTime); UpdateCamera(fElapsedTime); RenderWorld(fElapsedTime); @@ -1374,4 +1378,8 @@ void Crawler::InitializeLevels(){ INITLEVEL(CAMPAIGN_1_2); LEVEL_NAMES.SetInitialized(); +} + +void Crawler::SpawnMonster(vf2d pos,MonsterData*data,bool upperLevel){ + monstersToBeSpawned.push_back(Monster(pos,*data,upperLevel)); } \ No newline at end of file diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index 37bfa3ff..1241c876 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -47,6 +47,7 @@ private: float reflectionUpdateTimer=0; float reflectionStepTime=0; std::setvisibleTiles; + std::vectormonstersToBeSpawned; public: Crawler(); bool OnUserCreate() override; @@ -108,6 +109,7 @@ public: void RenderTile(vi2d pos,TilesheetData tileSheet,int tileSheetIndex,vi2d tileSheetPos); void RenderTile(TileRenderData&tileSheet,Pixel col); bool IsReflectiveTile(TilesheetData tileSheet,int tileID); + void SpawnMonster(vf2d pos,MonsterData*data,bool upperLevel=false); //Queues a monster for spawning on the next frame. struct TileGroupData{ vi2d tilePos; diff --git a/Crawler/DEFINES.h b/Crawler/DEFINES.h index e921d17c..37c07a6d 100644 --- a/Crawler/DEFINES.h +++ b/Crawler/DEFINES.h @@ -5,6 +5,7 @@ #define INCLUDE_DAMAGENUMBER_LIST extern std::vector>DAMAGENUMBER_LIST; #define INCLUDE_game extern Crawler*game; #define INCLUDE_MONSTER_DATA extern std::mapMONSTER_DATA; +#define INCLUDE_MONSTER_NAME_DATA extern safemapMONSTER_NAME_DATA; #define INCLUDE_BULLET_LIST extern std::vector>BULLET_LIST; #define INCLUDE_EMITTER_LIST extern std::vector>EMITTER_LIST; #define INCLUDE_DATA extern utils::datafile DATA; diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp index 43820736..4cab3f36 100644 --- a/Crawler/Monster.cpp +++ b/Crawler/Monster.cpp @@ -286,7 +286,7 @@ void MonsterSpawner::SetTriggered(bool trigger,bool spawnMonsters){ triggered=trigger; if(spawnMonsters){ for(std::pair&monsterInfo:monsters){ - MONSTER_LIST.push_back(Monster(pos+monsterInfo.second,MONSTER_DATA[monsterInfo.first],DoesUpperLevelSpawning())); + game->SpawnMonster(pos+monsterInfo.second,&MONSTER_DATA[monsterInfo.first],DoesUpperLevelSpawning()); } } } diff --git a/Crawler/MonsterData.cpp b/Crawler/MonsterData.cpp index 79b00c94..abd1eee8 100644 --- a/Crawler/MonsterData.cpp +++ b/Crawler/MonsterData.cpp @@ -10,6 +10,7 @@ INCLUDE_STRATEGY_DATA INCLUDE_ANIMATION_DATA std::mapMONSTER_DATA; +safemapMONSTER_NAME_DATA; MonsterData::MonsterData() :atk(0),collisionDmg(0),hp(0),id(0),moveSpd(0),size(0),strategy(0){} @@ -98,6 +99,7 @@ void MonsterData::InitializeMonsterData(){ ); MONSTER_DATA[id]=monster; + MONSTER_NAME_DATA[MonsterName]=&MONSTER_DATA[id]; id++; } diff --git a/Crawler/SlimeKing.cpp b/Crawler/SlimeKing.cpp index d944cf9e..d890d6d2 100644 --- a/Crawler/SlimeKing.cpp +++ b/Crawler/SlimeKing.cpp @@ -10,6 +10,7 @@ INCLUDE_game INCLUDE_BULLET_LIST INCLUDE_ANIMATION_DATA +INCLUDE_MONSTER_NAME_DATA typedef Attribute A; @@ -22,7 +23,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe 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); - auto ShootBulletRing=[&](float angleOffset){ + const auto ShootBulletRing=[&](float angleOffset){ int bulletCount=ConfigInt("Phase1.RingBulletCount"); for(int i=0;iSpawnMonster(m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12,MONSTER_NAME_DATA[spawnMonster]); + } + }break; + case 3:{ + std::string spawnMonster=ConfigStringArr("Phase3.MonsterSpawnOnChange",0); + int spawnCount=ConfigIntArr("Phase3.MonsterSpawnOnChange",1); + + for(int i=0;iSpawnMonster(m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12,MONSTER_NAME_DATA[spawnMonster]); + } + }break; + case 4:{ + std::string spawnMonster=ConfigStringArr("Phase4.MonsterSpawnOnChange",0); + int spawnCount=ConfigIntArr("Phase4.MonsterSpawnOnChange",1); + + for(int i=0;iSpawnMonster(m.pos+vf2d{cos(randomAngle),sin(randomAngle)}*m.GetSizeMult()*12,MONSTER_NAME_DATA[spawnMonster]); + } + }break; + case 5:{ + + }break; + } + }; + + const auto StartJump=[&](float jumpDuration,vf2d targetPos,float recoveryTime){ 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; @@ -112,6 +148,8 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe if(m.hp<=m.maxhp*ConfigFloat("Phase2.Change")/100){ m.phase=2; m.SetSize(ConfigFloat("Phase2.Size")/100,false); + TransitionPhase(m.phase); + return; } if(m.F(A::SHOOT_RING_TIMER)==0){ if(m.I(A::PATTERN_REPEAT_COUNT)>=ConfigInt("Phase1.JumpAfter")){ @@ -143,18 +181,24 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe if(m.hp<=m.maxhp*ConfigFloat("Phase3.Change")/100){ m.phase=3; m.SetSize(ConfigFloat("Phase3.Size")/100,false); + TransitionPhase(m.phase); + return; } }break; case 3:{ if(m.hp<=m.maxhp*ConfigFloat("Phase4.Change")/100){ m.phase=4; m.SetSize(ConfigFloat("Phase4.Size")/100,false); + TransitionPhase(m.phase); + return; } }break; case 4:{ if(m.hp<=0){ m.phase=5; m.F(A::IFRAME_TIME_UPON_HIT)=1; + TransitionPhase(m.phase); + return; } }break; } diff --git a/Crawler/Version.h b/Crawler/Version.h index 7350c2e0..6c74f57d 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 1334 +#define VERSION_BUILD 1342 #define stringify(a) stringify_(a) #define stringify_(a) #a