Change Bullet collision function name to make more sense. Implement collision radius property with a default value when unspecified, and allow setting to custom values individually from the size of the monster. Release Build 9272.

pull/57/head
sigonasr2 9 months ago
parent 2903c45d16
commit 29a36770aa
  1. 2
      Adventures in Lestoria/Bear.cpp
  2. 2
      Adventures in Lestoria/Bullet.cpp
  3. 2
      Adventures in Lestoria/FrogTongue.cpp
  4. 10
      Adventures in Lestoria/Monster.cpp
  5. 4
      Adventures in Lestoria/Monster.h
  6. 4
      Adventures in Lestoria/MonsterData.cpp
  7. 4
      Adventures in Lestoria/MonsterData.h
  8. 4
      Adventures in Lestoria/Stone_Elemental.cpp
  9. 2
      Adventures in Lestoria/Version.h
  10. 2
      Adventures in Lestoria/assets/config/Monsters.txt
  11. BIN
      Adventures in Lestoria/assets/gamepack.pak
  12. BIN
      x64/Release/Adventures in Lestoria.exe

@ -94,7 +94,7 @@ void Monster::STRATEGY::BEAR(Monster&m,float fElapsedTime,std::string strategy){
} }
} }
for(std::unique_ptr<Monster>&otherM:MONSTER_LIST){ for(std::unique_ptr<Monster>&otherM:MONSTER_LIST){
if(!otherM->AttackAvoided(m.GetZ())&&&m!=otherM.get()&&geom2d::overlaps(attackCircle,otherM->Hitbox())){ if(!otherM->AttackAvoided(m.GetZ())&&&m!=otherM.get()&&geom2d::overlaps(attackCircle,otherM->BulletCollisionHitbox())){
otherM->Knockup(ConfigFloat("Attack Knockup Duration")); otherM->Knockup(ConfigFloat("Attack Knockup Duration"));
vf2d monsterDirVecNorm=geom2d::line<float>(m.GetPos(),otherM->GetPos()).vector().norm(); vf2d monsterDirVecNorm=geom2d::line<float>(m.GetPos(),otherM->GetPos()).vector().norm();
game->GetPlayer()->Knockback(monsterDirVecNorm*ConfigFloat("Attack Knockback Amount")); game->GetPlayer()->Knockback(monsterDirVecNorm*ConfigFloat("Attack Knockback Amount"));

@ -91,7 +91,7 @@ void Bullet::_Update(const float fElapsedTime){
if(simulated)return true; if(simulated)return true;
if(friendly){ if(friendly){
for(std::unique_ptr<Monster>&m:MONSTER_LIST){ for(std::unique_ptr<Monster>&m:MONSTER_LIST){
if(geom2d::overlaps(m->Hitbox(),geom2d::circle(pos,radius))){ if(geom2d::overlaps(m->BulletCollisionHitbox(),geom2d::circle(pos,radius))){
if(hitList.find(&*m)==hitList.end()&&m->Hurt(damage,OnUpperLevel(),z)){ if(hitList.find(&*m)==hitList.end()&&m->Hurt(damage,OnUpperLevel(),z)){
if(!hitsMultiple){ if(!hitsMultiple){
if(MonsterHit(*m)){ if(MonsterHit(*m)){

@ -66,7 +66,7 @@ void FrogTongue::Update(float fElapsedTime){
} }
if(friendly){ if(friendly){
for(std::unique_ptr<Monster>&m:MONSTER_LIST){ for(std::unique_ptr<Monster>&m:MONSTER_LIST){
if(hitList.find(&*m)==hitList.end()&&geom2d::overlaps(m->Hitbox(),tongueLine)){ if(hitList.find(&*m)==hitList.end()&&geom2d::overlaps(m->BulletCollisionHitbox(),tongueLine)){
MonsterHit(*m); MonsterHit(*m);
hitList.insert(&*m); hitList.insert(&*m);
} }

@ -332,7 +332,7 @@ bool Monster::Update(float fElapsedTime){
if(!HasIframes()){ if(!HasIframes()){
for(std::unique_ptr<Monster>&m:MONSTER_LIST){ for(std::unique_ptr<Monster>&m:MONSTER_LIST){
if(&*m==this)continue; if(&*m==this)continue;
if(!m->HasIframes()&&OnUpperLevel()==m->OnUpperLevel()&&abs(m->GetZ()-GetZ())<=1&&geom2d::overlaps(geom2d::circle(pos,12*size/2),geom2d::circle(m->GetPos(),12*m->GetSizeMult()/2))){ if(!m->HasIframes()&&OnUpperLevel()==m->OnUpperLevel()&&abs(m->GetZ()-GetZ())<=1&&geom2d::overlaps(geom2d::circle(pos,GetCollisionRadius()),geom2d::circle(m->GetPos(),12*m->GetSizeMult()/2))){
m->Collision(*this); m->Collision(*this);
geom2d::line line(pos,m->GetPos()); geom2d::line line(pos,m->GetPos());
float dist = line.length(); float dist = line.length();
@ -343,7 +343,7 @@ bool Monster::Update(float fElapsedTime){
} }
} }
if(!Immovable()&& if(!Immovable()&&
!game->GetPlayer()->HasIframes()&&abs(game->GetPlayer()->GetZ()-GetZ())<=1&&game->GetPlayer()->OnUpperLevel()==OnUpperLevel()&&geom2d::overlaps(geom2d::circle(pos,12*size/2),geom2d::circle(game->GetPlayer()->GetPos(),12*game->GetPlayer()->GetSizeMult()/2))){ !game->GetPlayer()->HasIframes()&&abs(game->GetPlayer()->GetZ()-GetZ())<=1&&game->GetPlayer()->OnUpperLevel()==OnUpperLevel()&&geom2d::overlaps(geom2d::circle(pos,GetCollisionRadius()),geom2d::circle(game->GetPlayer()->GetPos(),12*game->GetPlayer()->GetSizeMult()/2))){
geom2d::line line(pos,game->GetPlayer()->GetPos()); geom2d::line line(pos,game->GetPlayer()->GetPos());
float dist = line.length(); float dist = line.length();
SetPos(line.rpoint(-0.1f)); SetPos(line.rpoint(-0.1f));
@ -873,8 +873,8 @@ const EventName&Monster::GetWalkSound(){
return MONSTER_DATA[name].GetWalkSound(); return MONSTER_DATA[name].GetWalkSound();
} }
geom2d::circle<float>Monster::Hitbox(){ geom2d::circle<float>Monster::BulletCollisionHitbox(){
return {GetPos(),12*GetSizeMult()}; return {GetPos(),GetCollisionRadius()*2};
} }
void Monster::Knockback(const vf2d&vel){ void Monster::Knockback(const vf2d&vel){
@ -1036,7 +1036,7 @@ const std::optional<float>Monster::GetLifetime()const{
const std::optional<float>Monster::GetTotalLifetime()const{ const std::optional<float>Monster::GetTotalLifetime()const{
return MONSTER_DATA.at(GetName()).GetLifetime(); return MONSTER_DATA.at(GetName()).GetLifetime();
} }
const std::optional<float>Monster::GetCollisionRadius()const{ const float Monster::GetCollisionRadius()const{
return MONSTER_DATA.at(GetName()).GetCollisionRadius(); return MONSTER_DATA.at(GetName()).GetCollisionRadius();
} }

@ -137,7 +137,7 @@ public:
void SetZ(float z); void SetZ(float z);
const std::function<void(Monster&,float,std::string)>&GetStrategy()const; const std::function<void(Monster&,float,std::string)>&GetStrategy()const;
void SetSize(float newSize,bool immediate=true); void SetSize(float newSize,bool immediate=true);
geom2d::circle<float>Hitbox(); geom2d::circle<float>BulletCollisionHitbox();
void SetStrategyDrawFunction(std::function<void(AiL*,Monster&,const std::string&)>func); void SetStrategyDrawFunction(std::function<void(AiL*,Monster&,const std::string&)>func);
void SetStrategyDrawOverlayFunction(std::function<void(AiL*,Monster&,const std::string&)>func); void SetStrategyDrawOverlayFunction(std::function<void(AiL*,Monster&,const std::string&)>func);
std::function<void(AiL*,Monster&,const std::string&)>strategyDraw=[](AiL*pge,Monster&m,const std::string&strategy){}; std::function<void(AiL*,Monster&,const std::string&)>strategyDraw=[](AiL*pge,Monster&m,const std::string&strategy){};
@ -170,7 +170,7 @@ public:
const std::optional<float>GetLifetime()const; const std::optional<float>GetLifetime()const;
const std::optional<float>GetTotalLifetime()const; const std::optional<float>GetTotalLifetime()const;
//If an object has a collision radius, returns it. //If an object has a collision radius, returns it.
const std::optional<float>GetCollisionRadius()const; const float GetCollisionRadius()const;
private: private:
//NOTE: Marking a monster for deletion does not trigger any death events. It just simply removes the monster from the field!! //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. // 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.

@ -169,6 +169,8 @@ void MonsterData::InitializeMonsterData(){
if(DATA["Monsters"][MonsterName].HasProperty("Immovable"))monster.immovable=DATA["Monsters"][MonsterName]["Immovable"].GetBool(); if(DATA["Monsters"][MonsterName].HasProperty("Immovable"))monster.immovable=DATA["Monsters"][MonsterName]["Immovable"].GetBool();
if(DATA["Monsters"][MonsterName].HasProperty("Invulnerable"))monster.invulnerable=DATA["Monsters"][MonsterName]["Invulnerable"].GetBool(); if(DATA["Monsters"][MonsterName].HasProperty("Invulnerable"))monster.invulnerable=DATA["Monsters"][MonsterName]["Invulnerable"].GetBool();
if(DATA["Monsters"][MonsterName].HasProperty("Lifetime"))monster.lifetime=DATA["Monsters"][MonsterName]["Lifetime"].GetReal(); if(DATA["Monsters"][MonsterName].HasProperty("Lifetime"))monster.lifetime=DATA["Monsters"][MonsterName]["Lifetime"].GetReal();
monster.collisionRadius=12*monster.GetSizeMult()/2.f;
if(DATA["Monsters"][MonsterName].HasProperty("Collision Radius"))monster.collisionRadius=DATA["Monsters"][MonsterName]["Collision Radius"].GetBool(); if(DATA["Monsters"][MonsterName].HasProperty("Collision Radius"))monster.collisionRadius=DATA["Monsters"][MonsterName]["Collision Radius"].GetBool();
if(hasFourWaySpriteSheet)monster.SetUsesFourWaySprites(); if(hasFourWaySpriteSheet)monster.SetUsesFourWaySprites();
@ -418,6 +420,6 @@ const bool MonsterData::Invulnerable()const{
const std::optional<float>MonsterData::GetLifetime()const{ const std::optional<float>MonsterData::GetLifetime()const{
return lifetime; return lifetime;
} }
const std::optional<float>MonsterData::GetCollisionRadius()const{ const float MonsterData::GetCollisionRadius()const{
return collisionRadius; return collisionRadius;
} }

@ -100,7 +100,7 @@ public:
//If an object has a lifetime set, returns it. //If an object has a lifetime set, returns it.
const std::optional<float>GetLifetime()const; const std::optional<float>GetLifetime()const;
//If an object has a collision radius, returns it. //If an object has a collision radius, returns it.
const std::optional<float>GetCollisionRadius()const; const float GetCollisionRadius()const;
private: private:
std::string name; std::string name;
int hp; int hp;
@ -127,5 +127,5 @@ private:
bool immovable{false}; bool immovable{false};
bool invulnerable{false}; bool invulnerable{false};
std::optional<float>lifetime{}; std::optional<float>lifetime{};
std::optional<float>collisionRadius{}; float collisionRadius{};
}; };

@ -85,10 +85,10 @@ void Monster::STRATEGY::STONE_ELEMENTAL(Monster&m,float fElapsedTime,std::string
} }
}break; }break;
case STONE_PILLAR_CAST:{ case STONE_PILLAR_CAST:{
m.PerformAnimation("STONE PILLAR CAST");
}break; }break;
case SHOOT_STONE_CAST:{ case SHOOT_STONE_CAST:{
m.PerformAnimation("ROCK TOSS CAST");
}break; }break;
case DIVE_UNDERGROUND_DIG:{ case DIVE_UNDERGROUND_DIG:{

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 9271 #define VERSION_BUILD 9272
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -764,6 +764,8 @@ Monsters
WALK = 4, 0.2, Repeat WALK = 4, 0.2, Repeat
TOSS ROCK = 4, 0.2, OneShot TOSS ROCK = 4, 0.2, OneShot
DEATH = 4, 0.15, OneShot DEATH = 4, 0.15, OneShot
BURROW UNDERGROUND = 5, 0.15, OneShot
RISE FROM UNDERGROUND = 5, 0.15, OneShot
ROCK TOSS CAST = 2, 0.3, Repeat ROCK TOSS CAST = 2, 0.3, Repeat
STONE PILLAR CAST = 2, 0.3, Repeat STONE PILLAR CAST = 2, 0.3, Repeat
} }

Loading…
Cancel
Save