diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index b42d6054..9b4e7f79 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2290,6 +2290,7 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){ hudOverlay.Reset(); backgroundEffects.clear(); foregroundEffects.clear(); + lockOnTargets.clear(); ItemDrop::drops.clear(); GameEvent::events.clear(); Audio::SetBGMPitch(1.f); @@ -4236,7 +4237,10 @@ void AiL::UpdateMonsters(){ MONSTER_LIST.push_back(std::make_unique(m)); if(MONSTER_LIST.capacity()>prevCapacity)LOG(std::format("WARNING! The monster list has automatically reserved more space and resized to {}! This caused one potential frame where bullet/effect hitlists that stored information on what monsters were hit to potentially be hit a second time or cause monsters that should've been hit to never be hit. Consider starting with a larger default reserved size for MONSTER_LIST if your intention was to have this many monsters!",MONSTER_LIST.capacity())); } - if(aMonsterIsMarkedForDeletion)std::erase_if(MONSTER_LIST,[](const std::unique_ptr&m){return m->markedForDeletion;}); + if(aMonsterIsMarkedForDeletion)std::erase_if(MONSTER_LIST,[](const std::unique_ptr&m){ + if(m->markedForDeletion)std::erase_if(lockOnTargets.begin(),lockOnTargets.end(),[&](const std::tuple&markData){return &*std::get<0>(markData)==m;}) //Marked targets may have dangling pointers, remove them before removing the monsters for good. + return m->markedForDeletion; + }); aMonsterIsMarkedForDeletion=false; game->monstersToBeSpawned.clear(); } @@ -4272,23 +4276,36 @@ void AiL::GlobalGameUpdates(){ ) #pragma region Damage Numbers update - for(std::vector>::iterator it=DAMAGENUMBER_LIST.begin();it!=DAMAGENUMBER_LIST.end();++it){ - DamageNumber*dn=(*it).get(); - if(dn->pauseTime>0){ - dn->pauseTime-=GetElapsedTime(); - } else{ - dn->lifeTime+=GetElapsedTime(); - if(dn->lifeTime<=1){ - if(dn->lifeTimeinvertedDirection){ - dn->pos.y+=dn->riseSpd*GetElapsedTime(); - }else{ - dn->pos.y-=dn->riseSpd*GetElapsedTime(); + for(std::vector>::iterator it=DAMAGENUMBER_LIST.begin();it!=DAMAGENUMBER_LIST.end();++it){ + DamageNumber*dn=(*it).get(); + if(dn->pauseTime>0){ + dn->pauseTime-=GetElapsedTime(); + } else{ + dn->lifeTime+=GetElapsedTime(); + if(dn->lifeTime<=1){ + if(dn->lifeTimeinvertedDirection){ + dn->pos.y+=dn->riseSpd*GetElapsedTime(); + }else{ + dn->pos.y-=dn->riseSpd*GetElapsedTime(); + } } } } } - } + #pragma endregion + + #pragma region Marked Targets Update + if(lockOnTargets.size()>0){ + lastLockOnTargetTime=std::max(0.f,lastLockOnTargetTime-GetElapsedTime()); + if(lastLockOnTargetTime<=0.f){ + const auto&[monster,stackCount,time]=lockOnTargets.front(); + monster->AddBuff(BuffType::TRAPPER_MARK,time,stackCount); + SoundEffect::PlaySFX("Lock On",monster->GetPos()); + lockOnTargets.erase(lockOnTargets.begin()); + lastLockOnTargetTime=0.2f; + } + } #pragma endregion if(GetMousePos()!=lastMousePos){ @@ -4416,4 +4433,8 @@ void AiL::PlayFootstepSound(){ const std::map&AiL::GetTilesets()const{ return MAP_TILESETS; +} + +void AiL::AddToMarkedTargetList(std::tuplemarkData){ + lockOnTargets.emplace_back(markData); } \ No newline at end of file diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index d31053c1..dc7345ee 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -69,6 +69,8 @@ BULLET_LIST.push_back(std::make_unique(type using HurtReturnValue=bool; using HurtList=std::vector,HurtReturnValue>>; +using StackCount=uint8_t; +using MarkTime=float; enum class HurtType{ PLAYER=0b01, @@ -227,6 +229,8 @@ private: Overlay hudOverlay{"pixel.png",BLANK}; float targetZoom{1.f}; float zoomAdjustSpeed{0.1f}; + std::vector>lockOnTargets; + float lastLockOnTargetTime{}; public: AiL(); bool OnUserCreate() override; @@ -381,6 +385,7 @@ public: //Plays the correct footstep sound based on player's current tile. void PlayFootstepSound(); const std::map&GetTilesets()const; + void AddToMarkedTargetList(std::tuplemarkData); struct TileGroupData{ vi2d tilePos; diff --git a/Adventures in Lestoria/Animation.cpp b/Adventures in Lestoria/Animation.cpp index 70f006b2..be155f05 100644 --- a/Adventures in Lestoria/Animation.cpp +++ b/Adventures in Lestoria/Animation.cpp @@ -270,70 +270,70 @@ void sig::Animation::InitializeAnimations(){ //Witch animations SetupClassWalkIdleAnimations(GFX["nico-witch.png"],"WITCH"); - Animate2D::FrameSequence pl_wizard_idle_attack_s; - pl_wizard_idle_attack_s.AddFrame({&GFX["nico-witch.png"],{vi2d{4,0}*24,{24,24}}}); - ANIMATION_DATA["WITCH_IDLE_ATTACK_S"]=pl_wizard_idle_attack_s; - Animate2D::FrameSequence pl_wizard_idle_attack_e; - pl_wizard_idle_attack_e.AddFrame({&GFX["nico-witch.png"],{vi2d{4,3}*24,{24,24}}}); - ANIMATION_DATA["WITCH_IDLE_ATTACK_E"]=pl_wizard_idle_attack_e; - Animate2D::FrameSequence pl_wizard_idle_attack_w; - pl_wizard_idle_attack_w.AddFrame({&GFX["nico-witch.png"],{vi2d{4,2}*24,{24,24}}}); - ANIMATION_DATA["WITCH_IDLE_ATTACK_W"]=pl_wizard_idle_attack_w; - Animate2D::FrameSequence pl_wizard_idle_attack_n; - pl_wizard_idle_attack_n.AddFrame({&GFX["nico-witch.png"],{vi2d{4,1}*24,{24,24}}}); - ANIMATION_DATA["WITCH_IDLE_ATTACK_N"]=pl_wizard_idle_attack_n; - Animate2D::FrameSequence pl_wizard_attack_s(0.2f); + Animate2D::FrameSequence pl_witch_idle_attack_s; + pl_witch_idle_attack_s.AddFrame({&GFX["nico-witch.png"],{vi2d{4,0}*24,{24,24}}}); + ANIMATION_DATA["WITCH_IDLE_ATTACK_S"]=pl_witch_idle_attack_s; + Animate2D::FrameSequence pl_witch_idle_attack_e; + pl_witch_idle_attack_e.AddFrame({&GFX["nico-witch.png"],{vi2d{4,3}*24,{24,24}}}); + ANIMATION_DATA["WITCH_IDLE_ATTACK_E"]=pl_witch_idle_attack_e; + Animate2D::FrameSequence pl_witch_idle_attack_w; + pl_witch_idle_attack_w.AddFrame({&GFX["nico-witch.png"],{vi2d{4,2}*24,{24,24}}}); + ANIMATION_DATA["WITCH_IDLE_ATTACK_W"]=pl_witch_idle_attack_w; + Animate2D::FrameSequence pl_witch_idle_attack_n; + pl_witch_idle_attack_n.AddFrame({&GFX["nico-witch.png"],{vi2d{4,1}*24,{24,24}}}); + ANIMATION_DATA["WITCH_IDLE_ATTACK_N"]=pl_witch_idle_attack_n; + Animate2D::FrameSequence pl_witch_attack_s(0.2f); for(int i=0;i<3;i++){ - pl_wizard_attack_s.AddFrame({&GFX["nico-witch.png"],{vi2d{4+i,0}*24,{24,24}}}); + pl_witch_attack_s.AddFrame({&GFX["nico-witch.png"],{vi2d{4+i,0}*24,{24,24}}}); if(i==1){ - pl_wizard_attack_s.AddFrame({&GFX["nico-witch.png"],{vi2d{4,0}*24,{24,24}}}); + pl_witch_attack_s.AddFrame({&GFX["nico-witch.png"],{vi2d{4,0}*24,{24,24}}}); } } - ANIMATION_DATA["WITCH_ATTACK_S"]=pl_wizard_attack_s; - Animate2D::FrameSequence pl_wizard_attack_e(0.2f); + ANIMATION_DATA["WITCH_ATTACK_S"]=pl_witch_attack_s; + Animate2D::FrameSequence pl_witch_attack_e(0.2f); for(int i=0;i<3;i++){ - pl_wizard_attack_e.AddFrame({&GFX["nico-witch.png"],{vi2d{4+i,3}*24,{24,24}}}); + pl_witch_attack_e.AddFrame({&GFX["nico-witch.png"],{vi2d{4+i,3}*24,{24,24}}}); if(i==1){ - pl_wizard_attack_e.AddFrame({&GFX["nico-witch.png"],{vi2d{4,3}*24,{24,24}}}); + pl_witch_attack_e.AddFrame({&GFX["nico-witch.png"],{vi2d{4,3}*24,{24,24}}}); } } - ANIMATION_DATA["WITCH_ATTACK_E"]=pl_wizard_attack_e; - Animate2D::FrameSequence pl_wizard_attack_w(0.2f); + ANIMATION_DATA["WITCH_ATTACK_E"]=pl_witch_attack_e; + Animate2D::FrameSequence pl_witch_attack_w(0.2f); for(int i=0;i<3;i++){ - pl_wizard_attack_w.AddFrame({&GFX["nico-witch.png"],{vi2d{4+i,2}*24,{24,24}}}); + pl_witch_attack_w.AddFrame({&GFX["nico-witch.png"],{vi2d{4+i,2}*24,{24,24}}}); if(i==1){ - pl_wizard_attack_w.AddFrame({&GFX["nico-witch.png"],{vi2d{4,2}*24,{24,24}}}); + pl_witch_attack_w.AddFrame({&GFX["nico-witch.png"],{vi2d{4,2}*24,{24,24}}}); } } - ANIMATION_DATA["WITCH_ATTACK_W"]=pl_wizard_attack_w; - Animate2D::FrameSequence pl_wizard_attack_n(0.2f); + ANIMATION_DATA["WITCH_ATTACK_W"]=pl_witch_attack_w; + Animate2D::FrameSequence pl_witch_attack_n(0.2f); for(int i=0;i<3;i++){ - pl_wizard_attack_n.AddFrame({&GFX["nico-witch.png"],{vi2d{4+i,1}*24,{24,24}}}); + pl_witch_attack_n.AddFrame({&GFX["nico-witch.png"],{vi2d{4+i,1}*24,{24,24}}}); if(i==1){ - pl_wizard_attack_n.AddFrame({&GFX["nico-witch.png"],{vi2d{4,1}*24,{24,24}}}); + pl_witch_attack_n.AddFrame({&GFX["nico-witch.png"],{vi2d{4,1}*24,{24,24}}}); } } - ANIMATION_DATA["WITCH_ATTACK_N"]=pl_wizard_attack_n; - Animate2D::FrameSequence pl_wizard_cast_s(0.1f); + ANIMATION_DATA["WITCH_ATTACK_N"]=pl_witch_attack_n; + Animate2D::FrameSequence pl_witch_cast_s(0.1f); for(int i=0;i<2;i++){ - pl_wizard_cast_s.AddFrame({&GFX["nico-witch.png"],{vi2d{7+i,0}*24,{24,24}}}); + pl_witch_cast_s.AddFrame({&GFX["nico-witch.png"],{vi2d{7+i,0}*24,{24,24}}}); } - ANIMATION_DATA["WITCH_CAST_S"]=pl_wizard_cast_s; - Animate2D::FrameSequence pl_wizard_cast_e(0.1f); + ANIMATION_DATA["WITCH_CAST_S"]=pl_witch_cast_s; + Animate2D::FrameSequence pl_witch_cast_e(0.1f); for(int i=0;i<2;i++){ - pl_wizard_cast_e.AddFrame({&GFX["nico-witch.png"],{vi2d{7+i,3}*24,{24,24}}}); + pl_witch_cast_e.AddFrame({&GFX["nico-witch.png"],{vi2d{7+i,3}*24,{24,24}}}); } - ANIMATION_DATA["WITCH_CAST_E"]=pl_wizard_cast_e; - Animate2D::FrameSequence pl_wizard_cast_n(0.1f); + ANIMATION_DATA["WITCH_CAST_E"]=pl_witch_cast_e; + Animate2D::FrameSequence pl_witch_cast_n(0.1f); for(int i=0;i<2;i++){ - pl_wizard_cast_n.AddFrame({&GFX["nico-witch.png"],{vi2d{7+i,1}*24,{24,24}}}); + pl_witch_cast_n.AddFrame({&GFX["nico-witch.png"],{vi2d{7+i,1}*24,{24,24}}}); } - ANIMATION_DATA["WITCH_CAST_N"]=pl_wizard_cast_n; - Animate2D::FrameSequence pl_wizard_cast_w(0.1f); + ANIMATION_DATA["WITCH_CAST_N"]=pl_witch_cast_n; + Animate2D::FrameSequence pl_witch_cast_w(0.1f); for(int i=0;i<2;i++){ - pl_wizard_cast_w.AddFrame({&GFX["nico-witch.png"],{vi2d{7+i,2}*24,{24,24}}}); + pl_witch_cast_w.AddFrame({&GFX["nico-witch.png"],{vi2d{7+i,2}*24,{24,24}}}); } - ANIMATION_DATA["WITCH_CAST_W"]=pl_wizard_cast_w; + ANIMATION_DATA["WITCH_CAST_W"]=pl_witch_cast_w; CreateHorizontalAnimationSequence("ground-slam-attack-back.png",5,{64,64},{0.02f,Animate2D::Style::OneShot}); CreateHorizontalAnimationSequence("ground-slam-attack-front.png",5,{64,64},{0.02f,Animate2D::Style::OneShot}); diff --git a/Adventures in Lestoria/BulletTypes.h b/Adventures in Lestoria/BulletTypes.h index e6913f0e..68268f4b 100644 --- a/Adventures in Lestoria/BulletTypes.h +++ b/Adventures in Lestoria/BulletTypes.h @@ -325,4 +325,4 @@ struct PurpleEnergyBall:public Bullet{ private: const vf2d initialScale; const float homingRadius; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index aadb95b1..e5a232da 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -1257,8 +1257,7 @@ void Monster::ApplyMark(float time,uint8_t stackCount){ } } }else{ - AddBuff(BuffType::TRAPPER_MARK,time,stackCount); - SoundEffect::PlaySFX("Lock On",GetPos()); + game->AddToMarkedTargetList({this,stackCount,time}); } markApplicationTimer=0.5f; } diff --git a/Adventures in Lestoria/assets/nico-Witch_512.png b/Adventures in Lestoria/assets/nico-Witch_512.png index c3036ebe..e90b24bc 100644 Binary files a/Adventures in Lestoria/assets/nico-Witch_512.png and b/Adventures in Lestoria/assets/nico-Witch_512.png differ diff --git a/Adventures in Lestoria/assets/nico-witch.png b/Adventures in Lestoria/assets/nico-witch.png index 8356ae10..55501c3c 100644 Binary files a/Adventures in Lestoria/assets/nico-witch.png and b/Adventures in Lestoria/assets/nico-witch.png differ diff --git a/Adventures in Lestoria/assets/nico-witch.xcf b/Adventures in Lestoria/assets/nico-witch.xcf index 045d9b18..c6ae7b31 100644 Binary files a/Adventures in Lestoria/assets/nico-witch.xcf and b/Adventures in Lestoria/assets/nico-witch.xcf differ