Fix up Opportunity Shot test to check with actual accessory equipped. Move camera initialization to a function. Camera starts at actual target location immediately (instead of lazy follow). Fix bug with lazy follow camera becoming ridiculous at low frame rates (>0.25s updates). MonsterData now provides a default collisionRadius in the constructor. 159/159 Tests Passing. Release Build 11039.

mac-build
sigonasr2 3 months ago
parent 45e6027c9e
commit 9005771f77
  1. 9
      Adventures in Lestoria Tests/EnchantTests.cpp
  2. 17
      Adventures in Lestoria/AdventuresInLestoria.cpp
  3. 1
      Adventures in Lestoria/AdventuresInLestoria.h
  4. 2
      Adventures in Lestoria/MonsterData.cpp
  5. 2
      Adventures in Lestoria/Version.h
  6. 2
      Adventures in Lestoria/olcUTIL_Camera2D.h
  7. BIN
      x64/Release/Adventures in Lestoria.exe

@ -100,6 +100,8 @@ namespace EnchantTests
MONSTER_DATA["TestName"]=testMonsterData;
#pragma endregion
testGame->InitializeCamera();
player=testGame->GetPlayer();
//Setup key "0" as a test input
testKeyboardInput.AddKeybind(Input{InputType::KEY,0});
@ -949,7 +951,7 @@ namespace EnchantTests
trap.MonsterHit(newMonster,1); //Simulate 1 mark stack on the monster to trigger the bleed.
Assert::AreEqual("Trapper.Ability 2.Marked Target Bleed"_f[1]+"Lingering Scent"_ENC["BLEED EXTRA DURATION"],newMonster.GetBuffs(BuffType::OVER_TIME)[0].duration,L"Bleed duration should be 10 seconds by default.");
}
TEST_METHOD(SpecialMarkNoEnchantCheck){
TEST_METHOD(OpportunityShotNoEnchantCheck){
game->ChangePlayerClass(TRAPPER);
player=game->GetPlayer();
Monster&newMonster{game->SpawnMonster({},MONSTER_DATA["TestName"])};
@ -959,9 +961,12 @@ namespace EnchantTests
}
Assert::AreEqual(size_t(0),newMonster.GetBuffs(BuffType::SPECIAL_MARK).size(),L"A special mark should not be spawned without the enchant.");
}
TEST_METHOD(SpecialMarkEnchantCheck){
TEST_METHOD(OpportunityShotEnchantCheck){
game->ChangePlayerClass(TRAPPER);
player=game->GetPlayer();
std::weak_ptr<Item>nullRing{Inventory::AddItem("Null Ring"s)};
Inventory::EquipItem(nullRing,EquipSlot::RING1);
nullRing.lock()->EnchantItem("Opportunity Shot");
Monster&newMonster{game->SpawnMonster({},MONSTER_DATA["TestName"])};
for(int i:std::ranges::iota_view(0,10)){
game->SetElapsedTime(1.f);

@ -309,11 +309,7 @@ bool AiL::OnUserCreate(){
InitializeLevels();
//Initialize Camera.
camera=Camera2D{WINDOW_SIZE};
camera.SetMode(olc::utils::Camera2D::Mode::LazyFollow);
camera.SetTarget(player->GetPos());
camera.SetWorldBoundary({0,0},GetCurrentMap().MapData.MapSize*GetCurrentMap().MapData.TileSize);
camera.EnableWorldBoundary(false);
InitializeCamera();
sig::Animation::SetupPlayerAnimations();
view=TileTransformedView{GetScreenSize(),{1,1}};
@ -3018,6 +3014,7 @@ void AiL::ChangePlayerClass(Class cl){
Player::moneyListeners=moneyListeners;
GetPlayer()->InitializeMinimapImage();
player->RecalculateEquipStats();
player->OnLevelStart();
}
void AiL::InitializeClasses(){
@ -4612,3 +4609,13 @@ std::vector<Effect*>AiL::GetAllEffects()const{
std::merge(foregroundEffects.begin(),foregroundEffects.end(),backgroundEffects.begin(),backgroundEffects.end(),std::back_inserter(outputVec));
return outputVec;
}
void AiL::InitializeCamera(){
camera=Camera2D{WINDOW_SIZE};
camera.SetMode(Camera2D::Mode::Simple);
camera.SetTarget(player->GetPos());
camera.Update(0.f);
camera.SetMode(olc::utils::Camera2D::Mode::LazyFollow);
camera.SetWorldBoundary({0,0},GetCurrentMap().MapData.MapSize*GetCurrentMap().MapData.TileSize);
camera.EnableWorldBoundary(false);
}

@ -392,6 +392,7 @@ public:
void AddToSpecialMarkedTargetList(std::tuple<std::weak_ptr<Monster>,StackCount,MarkTime>markData);
void InitializeClasses();
void _SetCurrentLevel(const MapName map); //NOTE: This will modify the currentLevel variable without triggering anything else in-game, this will normally mess up the state in the game. Ideally this is only used when initializing a test level.
void InitializeCamera();
std::vector<Effect*>GetForegroundEffects()const;
std::vector<Effect*>GetBackgroundEffects()const;

@ -52,7 +52,7 @@ std::map<std::string,MonsterData>MONSTER_DATA;
MonsterData::MonsterData()
:atk(0),collisionDmg(0),hp(0),moveSpd(0),size(0),strategy("Run Towards"){}
MonsterData::MonsterData(std::string name,std::string displayName,int hp,int atk,const uint32_t xp,std::vector<MonsterDropData>drops,float moveSpd,float size,std::string strategy,int collisionDmg):
name(name),displayName(displayName),hp(hp),atk(atk),xp(xp),moveSpd(moveSpd),size(size),strategy(strategy),dropData(drops),collisionDmg(collisionDmg){}
name(name),displayName(displayName),hp(hp),atk(atk),xp(xp),moveSpd(moveSpd),size(size),strategy(strategy),dropData(drops),collisionDmg(collisionDmg),collisionRadius(8.f*this->size){}
void MonsterData::InitializeMonsterData(){
for(auto&[key,size]:DATA["Monsters"].GetKeys()){

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_PATCH 3
#define VERSION_BUILD 11031
#define VERSION_BUILD 11039
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -216,7 +216,7 @@ namespace olc::utils
case Mode::LazyFollow:
{
m_vPosition += (GetTarget() - m_vPosition) * m_fLazyFollowRate * fElapsedTime;
m_vPosition += (GetTarget() - m_vPosition) * std::min(1.f,m_fLazyFollowRate * fElapsedTime);
}
break;

Loading…
Cancel
Save