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.

mac-build
sigonasr2 7 months ago
parent dce39df412
commit ad04f89526
  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){
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"));
vf2d monsterDirVecNorm=geom2d::line<float>(m.GetPos(),otherM->GetPos()).vector().norm();
game->GetPlayer()->Knockback(monsterDirVecNorm*ConfigFloat("Attack Knockback Amount"));

@ -91,7 +91,7 @@ void Bullet::_Update(const float fElapsedTime){
if(simulated)return true;
if(friendly){
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(!hitsMultiple){
if(MonsterHit(*m)){

@ -66,7 +66,7 @@ void FrogTongue::Update(float fElapsedTime){
}
if(friendly){
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);
hitList.insert(&*m);
}

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

@ -137,7 +137,7 @@ public:
void SetZ(float z);
const std::function<void(Monster&,float,std::string)>&GetStrategy()const;
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 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){};
@ -170,7 +170,7 @@ public:
const std::optional<float>GetLifetime()const;
const std::optional<float>GetTotalLifetime()const;
//If an object has a collision radius, returns it.
const std::optional<float>GetCollisionRadius()const;
const float GetCollisionRadius()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.

@ -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("Invulnerable"))monster.invulnerable=DATA["Monsters"][MonsterName]["Invulnerable"].GetBool();
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(hasFourWaySpriteSheet)monster.SetUsesFourWaySprites();
@ -418,6 +420,6 @@ const bool MonsterData::Invulnerable()const{
const std::optional<float>MonsterData::GetLifetime()const{
return lifetime;
}
const std::optional<float>MonsterData::GetCollisionRadius()const{
const float MonsterData::GetCollisionRadius()const{
return collisionRadius;
}

@ -100,7 +100,7 @@ public:
//If an object has a lifetime set, returns it.
const std::optional<float>GetLifetime()const;
//If an object has a collision radius, returns it.
const std::optional<float>GetCollisionRadius()const;
const float GetCollisionRadius()const;
private:
std::string name;
int hp;
@ -127,5 +127,5 @@ private:
bool immovable{false};
bool invulnerable{false};
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;
case STONE_PILLAR_CAST:{
m.PerformAnimation("STONE PILLAR CAST");
}break;
case SHOOT_STONE_CAST:{
m.PerformAnimation("ROCK TOSS CAST");
}break;
case DIVE_UNDERGROUND_DIG:{

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

@ -764,6 +764,8 @@ Monsters
WALK = 4, 0.2, Repeat
TOSS ROCK = 4, 0.2, 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
STONE PILLAR CAST = 2, 0.3, Repeat
}

Loading…
Cancel
Save