[Compiler Error] Implement delayed lock-on targeting when multiple targets get marks at the same time (for more dramatic effect)

removeExposedPackKey
NicoNicoNii 4 months ago
parent 23c2bfb45c
commit 5a7c60ac7c
  1. 49
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 5
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 80
      Adventures in Lestoria/Animation.cpp
  4. 2
      Adventures in Lestoria/BulletTypes.h
  5. 3
      Adventures in Lestoria/Monster.cpp
  6. BIN
      Adventures in Lestoria/assets/nico-Witch_512.png
  7. BIN
      Adventures in Lestoria/assets/nico-witch.png
  8. BIN
      Adventures in Lestoria/assets/nico-witch.xcf

@ -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<Monster>(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<Monster>&m){return m->markedForDeletion;});
if(aMonsterIsMarkedForDeletion)std::erase_if(MONSTER_LIST,[](const std::unique_ptr<Monster>&m){
if(m->markedForDeletion)std::erase_if(lockOnTargets.begin(),lockOnTargets.end(),[&](const std::tuple<Monster*,StackCount,MarkTime>&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<std::shared_ptr<DamageNumber>>::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->lifeTime<DamageNumber::MOVE_UP_TIME){
if(dn->invertedDirection){
dn->pos.y+=dn->riseSpd*GetElapsedTime();
}else{
dn->pos.y-=dn->riseSpd*GetElapsedTime();
for(std::vector<std::shared_ptr<DamageNumber>>::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->lifeTime<DamageNumber::MOVE_UP_TIME){
if(dn->invertedDirection){
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<std::string,TilesetData>&AiL::GetTilesets()const{
return MAP_TILESETS;
}
void AiL::AddToMarkedTargetList(std::tuple<Monster*,StackCount,MarkTime>markData){
lockOnTargets.emplace_back(markData);
}

@ -69,6 +69,8 @@ BULLET_LIST.push_back(std::make_unique<type>(type
using HurtReturnValue=bool;
using HurtList=std::vector<std::pair<std::variant<Monster*,Player*>,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<std::tuple<Monster*,StackCount,MarkTime>>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<std::string,TilesetData>&GetTilesets()const;
void AddToMarkedTargetList(std::tuple<Monster*,StackCount,MarkTime>markData);
struct TileGroupData{
vi2d tilePos;

@ -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});

@ -325,4 +325,4 @@ struct PurpleEnergyBall:public Bullet{
private:
const vf2d initialScale;
const float homingRadius;
}
};

@ -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;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Loading…
Cancel
Save