diff --git a/olcCodeJam2023Entry/Info.txt b/olcCodeJam2023Entry/Info.txt index 880647b..78ca2d6 100644 --- a/olcCodeJam2023Entry/Info.txt +++ b/olcCodeJam2023Entry/Info.txt @@ -34,6 +34,7 @@ Day 6 Multiple Levels Day 7 Scenario Writing Hotkeys Day 8 Scenario Writing +Fake allies the narrator forgot to switch ovr (Customized Units...?) Day 9 Sounds/Music/Menus - Timer (Speedrun) Difficulty Selection Ending...Shows Four Seasons of Loneliness boss zoom out... diff --git a/olcCodeJam2023Entry/Unit.cpp b/olcCodeJam2023Entry/Unit.cpp index 0b94f40..0c0016e 100644 --- a/olcCodeJam2023Entry/Unit.cpp +++ b/olcCodeJam2023Entry/Unit.cpp @@ -46,7 +46,7 @@ void BitRestorer::Attack(Unit&victim,std::vector>&otherUni return; } int randomBit=emptyMemoryPositions[rand()%emptyMemoryPositions.size()]; - victim.memory[randomBit]=victim.ghostMemory[randomBit]=true; + victim.memory[randomBit]=true; } void BitRestorer::AttemptToHealOtherAllies(std::vector>&otherUnits){ @@ -60,7 +60,7 @@ void BitRestorer::AttemptToHealOtherAllies(std::vector>&ot } if(emptyMemoryPositions.size()!=0){ int randomBit=emptyMemoryPositions[rand()%emptyMemoryPositions.size()]; - u->memory[randomBit]=u->ghostMemory[randomBit]=true; + u->memory[randomBit]=true; appliedTarget=u; return; } @@ -79,12 +79,12 @@ MemorySwapper::MemorySwapper(PixelGameEngine*pge,vf2d pos,std::map>&otherUnits){ std::vectoroldMemory=victim.memory; for(int i=0;iorder; for(int i=0;i<5;i++){ int lowestInd=999999; - Marker*lowest; + Marker*lowest=nullptr; if(victim.health.indexindex;} if(victim.range.indexindex;} if(victim.atkSpd.indexindex;} @@ -102,6 +102,12 @@ void MemorySwapper::Attack(Unit&victim,std::vector>&otherU marker+=order[i]->size; i++; } + //Clean up after ourselves for any 0-sized stats. + if(victim.health.index==9999999)victim.health.index=0; + if(victim.range.index==9999999)victim.range.index=0; + if(victim.atkSpd.index==9999999)victim.atkSpd.index=0; + if(victim.moveSpd.index==9999999)victim.moveSpd.index=0; + if(victim.procedure.index==9999999)victim.procedure.index=0; } std::string Corrupter::unitName="Corrupter"; @@ -113,7 +119,7 @@ Corrupter::Corrupter(PixelGameEngine*pge,vf2d pos,std::map>&otherUnits){ //Chooses a bit at random and corrupts it. int randomBit=rand()%victim.memory.size(); - victim.memory[randomBit]=victim.ghostMemory[randomBit]=false; + victim.memory[randomBit]=false; } std::string MemoryAllocator::unitName="Memory Allocator"; @@ -291,7 +297,7 @@ Refresher::Refresher(PixelGameEngine*pge,vf2d pos,std::map>&otherUnits){ //Chooses a bit at random and corrupts it. int randomBit=rand()%victim.memory.size(); - victim.memory[randomBit]=victim.ghostMemory[randomBit]=false; + victim.memory[randomBit]=false; } std::string Turret::unitName="Turret"; @@ -303,7 +309,7 @@ Turret::Turret(PixelGameEngine*pge,vf2d pos,std::map>&otherUnits){ //Chooses a bit at random and corrupts it. int randomBit=rand()%victim.memory.size(); - victim.memory[randomBit]=victim.ghostMemory[randomBit]=false; + victim.memory[randomBit]=false; } std::string MemoryGuard::unitName="Memory Guard"; @@ -412,19 +418,19 @@ void Unit::_DrawHud(TileTransformedView&game,std::map0){ col=CONSTANT::HEALTH_COLOR; } - if(range.index==i){ + if(range.index==i&&range.size>0){ col=CONSTANT::RANGE_COLOR; } - if(atkSpd.index==i){ + if(atkSpd.index==i&&atkSpd.size>0){ col=CONSTANT::ATKSPD_COLOR; } - if(moveSpd.index==i){ + if(moveSpd.index==i&&moveSpd.size>0){ col=CONSTANT::MOVESPD_COLOR; } - if(procedure.index==i){ + if(procedure.index==i&&procedure.size>0){ col=CONSTANT::PROCEDURE_COLOR; } }; @@ -616,6 +622,10 @@ void Unit::_Update(PixelGameEngine*pge,std::map>&SO HideGhost(); } + if(!InFogOfWar()){ + ghostMemory=memory; + } + reloadTimer=std::max(0.f,reloadTimer-pge->GetElapsedTime()); guardTime=std::max(0.f,guardTime-pge->GetElapsedTime()); lineShift-=pge->GetElapsedTime(); diff --git a/olcCodeJam2023Entry/Unit.h b/olcCodeJam2023Entry/Unit.h index 40c06f3..3a9a4a2 100644 --- a/olcCodeJam2023Entry/Unit.h +++ b/olcCodeJam2023Entry/Unit.h @@ -106,9 +106,6 @@ public: memory[i]=memory[i+1]; } memory[GetMemorySize()-1]=0; - if(!InFogOfWar()){ - ghostMemory=memory; - } return memory; } @@ -117,9 +114,6 @@ public: memory[i]=memory[i-1]; } memory[0]=0; - if(!InFogOfWar()){ - ghostMemory=memory; - } return memory; } protected: diff --git a/olcCodeJam2023Entry/VirusAttack.cpp b/olcCodeJam2023Entry/VirusAttack.cpp index 45114b4..bb6d18e 100644 --- a/olcCodeJam2023Entry/VirusAttack.cpp +++ b/olcCodeJam2023Entry/VirusAttack.cpp @@ -336,6 +336,16 @@ void VirusAttack::DrawSelectionRectangle(){ void VirusAttack::HandleRightClickMove(){ if (GetMouse(1).bHeld){ bool selectedTarget=false; + if(GetMouseX()>=ScreenWidth()-64&&GetMouseY()>=ScreenHeight()-64){//Clicked on Minimap. + for(auto&u:units){ + if(u->IsFriendly()&&u->IsSelected()&&u->CanMove()){ + vf2d minimapTL=GetScreenSize()-vf2d{64,64}; + vf2d minimapCenterClick=vf2d(GetMousePos()-minimapTL)/64*WORLD_SIZE*CONSTANT::TILE_SIZE-vf2d(GetScreenSize())/game.GetWorldScale()/2.f+vf2d(GetScreenSize()/2.f)/game.GetWorldScale(); + u->SetTargetLocation(minimapCenterClick); + } + } + goto targetFound; + } for(auto&u:units){ if(geom2d::overlaps(geom2d::circle(u->GetPos(),u->GetUnitSize().x/2),GetWorldMousePos())){ for(auto&u2:units){ @@ -680,7 +690,7 @@ bool VirusAttack::OnUserUpdate(float fElapsedTime){ } } if(changeOccured&&util::random(1)<=0.3){ - u->memory[changedBit]=u->ghostMemory[changedBit]=u->savedMemory[changedBit]; + u->memory[changedBit]=u->savedMemory[changedBit]; } } }