diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index 8392e436..e398bfa6 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -1168,4 +1168,8 @@ const float Monster::GetModdedStatBonuses(std::string_view stat)const{ } } return flatBonuses+flatBonuses*pctBonusSum/100.f; +} + +const std::optional>&Monster::GetRectangleCollision()const{ + return MONSTER_DATA.at(GetName()).GetRectangleCollision(); } \ No newline at end of file diff --git a/Adventures in Lestoria/Monster.h b/Adventures in Lestoria/Monster.h index 5eed8159..066ca11a 100644 --- a/Adventures in Lestoria/Monster.h +++ b/Adventures in Lestoria/Monster.h @@ -198,6 +198,8 @@ public: void _DealTrueDamage(const uint32_t damageAmt); void Heal(const int healAmt); const float GetModdedStatBonuses(std::string_view stat)const; + //The collision rectangle is only used currently for determining the safe spots for the stone golem boss fight. + const std::optional>&GetRectangleCollision()const; private: //NOTE: Marking a monster for deletion does not trigger any death events. It just simply removes the monster from the field!! // The way this works is that monsters marked for deletion will cause the monster update loop to detect there's at least one or more monsters that must be deleted and will call erase_if on the list at the end of the iteration loop. diff --git a/Adventures in Lestoria/MonsterData.cpp b/Adventures in Lestoria/MonsterData.cpp index ee1890a8..8569aa4f 100644 --- a/Adventures in Lestoria/MonsterData.cpp +++ b/Adventures in Lestoria/MonsterData.cpp @@ -189,6 +189,11 @@ void MonsterData::InitializeMonsterData(){ if(DATA["Monsters"][MonsterName].HasProperty("Collision Radius"))monster.collisionRadius=DATA["Monsters"][MonsterName]["Collision Radius"].GetReal(); if(DATA["Monsters"][MonsterName].HasProperty("ShowBossIndicator"))monster.hasArrowIndicator=DATA["Monsters"][MonsterName]["ShowBossIndicator"].GetBool(); + if(DATA["Monsters"][MonsterName].HasProperty("Rectangle Collision")){ + const datafile&rectData{DATA["Monsters"][MonsterName]["Rectangle Collision"]}; + monster.rectCollision={{rectData.GetReal(0),rectData.GetReal(1)},{rectData.GetReal(2),rectData.GetReal(3)}}; + } + if(hasFourWaySpriteSheet)monster.SetUsesFourWaySprites(); for(size_t animationRow=0;const std::string&animationName:animations){ @@ -444,4 +449,8 @@ const float MonsterData::GetCollisionRadius()const{ } const bool MonsterData::HasArrowIndicator()const{ return hasArrowIndicator; +} + +const std::optional>&MonsterData::GetRectangleCollision()const{ + return rectCollision; } \ No newline at end of file diff --git a/Adventures in Lestoria/MonsterData.h b/Adventures in Lestoria/MonsterData.h index c379dc23..0bdba432 100644 --- a/Adventures in Lestoria/MonsterData.h +++ b/Adventures in Lestoria/MonsterData.h @@ -105,6 +105,7 @@ public: //If an object has a collision radius, returns it. const float GetCollisionRadius()const; const bool HasArrowIndicator()const; + const std::optional>&GetRectangleCollision()const; private: std::string name; int hp; @@ -134,4 +135,5 @@ private: std::optionallifetime{}; float collisionRadius{}; bool hasArrowIndicator{false}; + std::optional>rectCollision; }; \ No newline at end of file diff --git a/Adventures in Lestoria/StoneGolem.cpp b/Adventures in Lestoria/StoneGolem.cpp index 36d42fa7..4c7c4b3a 100644 --- a/Adventures in Lestoria/StoneGolem.cpp +++ b/Adventures in Lestoria/StoneGolem.cpp @@ -71,10 +71,11 @@ void Monster::STRATEGY::STONE_GOLEM(Monster&m,float fElapsedTime,std::string str #pragma region Solve for Safe Quad //First draw 4 lines to the corners. - const vf2d upperLeftCorner{pillar.GetPos()+vf2d{-8,-8}*pillar.GetSizeMult()}; - const vf2d upperRightCorner{pillar.GetPos()+vf2d{8,-8}*pillar.GetSizeMult()}; - const vf2d lowerLeftCorner{pillar.GetPos()+vf2d{-8,8}*pillar.GetSizeMult()}; - const vf2d lowerRightCorner{pillar.GetPos()+vf2d{8,8}*pillar.GetSizeMult()}; + const geom2d::rect&collisionRect{pillar.GetRectangleCollision().value()}; + const vf2d upperLeftCorner{pillar.GetPos()+collisionRect.pos*pillar.GetSizeMult()}; + const vf2d upperRightCorner{pillar.GetPos()+(collisionRect.pos+vf2d{collisionRect.size.x,0.f})*pillar.GetSizeMult()}; + const vf2d lowerLeftCorner{pillar.GetPos()+(collisionRect.pos+vf2d{collisionRect.size.y,0.f})*pillar.GetSizeMult()}; + const vf2d lowerRightCorner{pillar.GetPos()+(collisionRect.pos+collisionRect.size)*pillar.GetSizeMult()}; const std::vectorcorners{upperLeftCorner,upperRightCorner,lowerLeftCorner,lowerRightCorner}; diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index a9fe173f..2d140d65 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 3 -#define VERSION_BUILD 9947 +#define VERSION_BUILD 9948 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/config/Monsters.txt b/Adventures in Lestoria/assets/config/Monsters.txt index 25807724..06483a70 100644 --- a/Adventures in Lestoria/assets/config/Monsters.txt +++ b/Adventures in Lestoria/assets/config/Monsters.txt @@ -1066,6 +1066,10 @@ Monsters # The Pillar is supposed to be 350 radius. Size = 600% Collision Radius = 7 + # If provided, constructs a rectangular collision instance for this enemy. + # Args: Pos X,Pos Y,Width,Height. + # NOTE: Position coordinates are relative. + Rectangle Collision = -4,-4,8,8 XP = 0